android - TypeError: Cannot read property 'udp' of undefined -
i need write ionic app sends , recieves udp packets. i'm using plugin android: https://github.com/mobilechromeapps/cordova-plugin-chrome-apps-sockets-udp
this code in app.js:
$scope.connect = function() { var socketid; // handle "onreceive" event. var onreceive = function(info) { if (info.socketid !== socketid) return; console.log(info.data); }; // create socket chrome.sockets.udp.create({}, function(socketinfo) { socketid = socketinfo.socketid; // setup event handler , bind socket. chrome.sockets.udp.onreceive.addlistener(onreceive); chrome.sockets.udp.bind(socketid, "0.0.0.0", 55555, function(result) { if (result < 0) { console.log("error binding socket."); return; } var arraybuffer = new arraybuffer(20); var dv = new dataview(arraybuffer,0); dv.setuint16(0,0); dv.setuint16(1,12); dv.setuint16(2,0); dv.setuint16(3,0); dv.setuint32(4,0); dv.setuint32(5,55555); dv.setuint32(6,0); console.log("here"); chrome.sockets.udp.send(socketid, arraybuffer, '127.0.0.1', 2222, function(sendinfo) { console.log("sent " + sendinfo.bytessent); }); }); }); }})
(this same example taken here: https://developer.chrome.com/apps/app_network (for udp)
i understand need give udp permissions in kind of manifest file, can that? have android.jason file , androidmanifest.xml file.
thanks alot!
Comments
Post a Comment