# Mobile Phone WeChat Calling Device (Linux Direct Connection)
Requires plug-in version 2.4.0, Linux SDK 0x00097 start support
If you want to get various events during the call, you can use the plug-in
onVoipEventInterface.
# 1. Phone WeChat side to initiate a call
Before initiating a call, users typically need to select the device to call and the type of call (audio / video) in Weixin Mini Program.
When initiating a call, the developer needs and invokes the plug-in's callDevice The interface gets the roomId and then jumps to the plugin's Initiate Call page.
const wmpfVoip = requirePlugin('wmpf-voip').default
try {
const { roomId } = await wmpfVoip.callDevice({
roomType: 'video', // 房间类型。voice: 音频房间;video: 视频房间
sn: '设备 SN',
modelId: '设备 modelId',
nickName: '设备端显示的微信用户名称',
deviceName: '我的学习机',
})
if (/* 当前不在插件页面 */) {
wx.redirectTo({
url: wmpfVoip.CALL_PAGE_PATH,
})
}
} catch (e) {
console.error('callDevice failed:', e)
wx.showToast({
title: '呼叫失败',
icon: 'error',
})
}
# 2. Push call reminders
After the phone WeChat call, the developer should use its own message channel, the roomId and other devices to join the room required parameter passing to the device.
# 3. Accept calls from the device
After receiving a call reminder, the device side first creates a Session using thewx_voip_session_newinterface, and then uses thewx_voip_listener_jointo answer.Other interfaces are used similarly to a device calling a phone.After the session is created, you can call thewx_voip_session_hangupinterface to end the call.For details, please refer to < Weixin Mini Program Audio and Video Calling SDK (Linux) > .
# 4. The device refuses to call
When the device receives a call alert, it can callwx_voip_listener_hangup(Can only be called before the Session is created) to end the call, to achieve busy line or rejection.For details, please refer to < Weixin Mini Program Audio and Video Calling SDK (Linux) > .