如何以编程方式点亮 Cisco IP 电话可视留言等待指示灯(VMWI 或 MWI)?
对于 sipwiz 答案:
IP地址10.1.1.2 =>是我将发送SIP通知消息的本地IP
IP 地址10.1.1.9 => 是我将发送 SIP 消息的思科电话的 IP 地址
The Cisco Phone that I send SIP Message does "care" my messages, and I got exception while i try to get response messge from Cisco Phone :"An existing connection was forcibly closed by the remote host".
实际上,直接向 Cisco Phone 发送 SIP 消息来改变其行为似乎并不正确。因为它容易出现许多安全违规行为。而且我认为 Cisco 不会允许这样做。
"sipwiz" do I need to do extra configuration on Cisco Phone to make this feature work? Do you actually able to make it work on a real Cisco Phone? If so, what kind of extra config yo do on the Phone?
最佳答案
下面是一些粗略的代码,用于构造一个虚拟 SIP NOTIFY 请求,该请求可以发送到 Cisco IP 电话(仅使用 Cisco 7960 进行测试),从而允许设置和取消设置可视消息等待指示器。
您需要更改 sip:[email protected]到您的 Cisco 电话可识别的 SIP URI。当然,还要根据需要调整 IP 地址和端口。
更新:更新了代码示例,使其更清楚 IP 地址需要在 SIP 请求中的位置。
using System;
using System.Collections.Generic;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Cisco MWI Test Console:");
string setMWIRequest =
"NOTIFY {0} SIP/2.0\r\n" +
"Via: SIP/2.0/UDP {1}:{2};branch=z9hG4bK{3}\r\n" +
"To: <{0}>\r\n" +
"From: <{0}>\r\n" +
"Call-ID: {4}\r\n" +
"CSeq: 1 NOTIFY\r\n" +
"Max-Forwards: 70\r\n" +
"Contact: {1}:{2}\r\n" +
"Content-Length: {5}\r\n" +
"Content-Type: application/simple-message-summary\r\n" +
"Event: message-summary\r\n" +
"\r\n" +
"{6}";
string mwiBody = "Messages-Waiting: no"; // Change to no to unset MWI.
var localSIPEP = new IPEndPoint(IPAddress.Parse("192.168.33.116"), 5091);
Socket udpSocket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
udpSocket.Bind(localSIPEP);
setMWIRequest = String.Format(setMWIRequest, "sip:<a href="https://stackoverflow.com/cdn-cgi/l/email-protection" class="__cf_email__" data-cfemail="aedbddcbdceeddcbdcd8cbdc80cdc1c3" rel="noreferrer noopener nofollow">[email protected]</a>", localSIPEP.Address.ToString(), localSIPEP.Port, Guid.NewGuid().ToString().Replace("-", ""), Guid.NewGuid().ToString().Replace("-", ""), mwiBody.Length, mwiBody);
byte[] buffer = Encoding.UTF8.GetBytes(setMWIRequest);
Console.WriteLine("Sending to Cisco:");
Console.WriteLine(setMWIRequest);
udpSocket.SendTo(buffer, new IPEndPoint(IPAddress.Parse("192.168.33.155"), 5060));
byte[] recvBuffer = new byte[4096];
int bytesRead = udpSocket.Receive(recvBuffer);
Console.WriteLine(Encoding.UTF8.GetString(recvBuffer.Take(bytesRead).ToArray()));
Console.ReadLine();
}
}
关于sip - 思科可视消息等待指示器(VMWI 或 MVI),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/21260123/