UPnPの実装
Last updated
HetiSocketBuilder _socketBuilder = new HetiSocketBuilderChrome();
HetiUdpSocket _socket = _socketBuilder.createUdpClient();
_socket.onReceive().listen((HetiReceiveUdpInfo info) {
print("receive udp info");
});
_socket.bind("0.0.0.0", 0).then((int v){
if (v >=0) {
print("bind ok");
} else {
print("bind error");
}
}_socket.send(
convert.UTF8.encode(SSDP_M_SEARCH_WANPPPConnectionV1),
SSDP_ADDRESS,
SSDP_PORT).then((HetiUdpSendInfo iii) {
print("send ok");
}).catchError((e) {
completer.completeError(e);
});M-SEARCH * HTTP/1.1
MX: 3
HOST: 239.255.255.250:1900
MAN: "ssdp:discover"
ST: urn:schemas-upnp-org:service:WANIPConnection:1HetiHttpClient client = new HetiHttpClient(new HetiSocketBuilderChrome()));
client.connect(host, port).then((int v) {
return client.post(path, convert.UTF8.encode(body), {
KEY_SOAPACTION: soapAction,
"Content-Type": "text/xml"
});
}).then((HetiHttpClientResponse response) {
print("receive response");
}).catchError((e){
print("failed request");
});UpnpDeviceSearcher
.createInstance(new hetimacl.HetiSocketBuilderChrome())
.then((hetima.UpnpDeviceSearcher searcher) {
searcher.onReceive().listen((hetima.UPnpDeviceInfo info) {
});
searcher.searchWanPPPDevice();
});UpnpPPPDevice#addPortMapping(
localIP,
localPort,
remotePort,
UPnpPPPDevice.VALUE_PORT_MAPPING_PROTOCOL_TCP)
.then((UpnpPortMappingResult r) {
});UpnpPPPDevice#requestGetExternalIPAddress()
.then((String address){
});UpnpPPPDevice#addPortMapping(
localIP,
localPort,
remotePort,
UPnpPPPDevice.VALUE_PORT_MAPPING_PROTOCOL_TCP)
.then((UpnpPortMappingResult r) {
});UpnpPPPDevice#requestGetExternalIPAddress()
.then((String address){
});