我正在尝试在c#中构建一个upnp设备。我已经实现了订阅者,但是当我尝试通知变量状态更改时,消息没有收听。 为了测试订阅和事件,我正在使用英特尔的Device Spy。
这里是发送通知的代码:
try
{
HostName host = new HostName(hostName);
StreamSocket _socket = new StreamSocket();
await _socket.ConnectAsync(host, portNumber.ToString());
var html = Encoding.UTF8.GetBytes(message);
DataWriter dw = new DataWriter(_socket.OutputStream);
dw.WriteString(message);
await dw.StoreAsync();
}
catch (Exception ex)
{
}
这里是发送数据包:
NOTIFY /65088E88-1082-4AC9-98D2-111DF151507D/urn:upnp-org:serviceId:ACDLServiceID HTTP/1.1
HOST: 10.10.50.161:58583
CONTENT-TYPE: text/xml; charset="utf-8"
CONTENT-LENGHT: 126
NT: upnp:event
NTS: upnp:propchange
SID: uuid:8937a19d-bf7b-4903-8875-e5992abe975b
SEQ: 0
<e:propertyset xmlns:e="urn:schemas-upnp-org:event-1-0"><e:property><led_state>Acceso</led_state></e:property></e:propertyset>
有什么问题? 谢谢