Created
February 1, 2014 12:40
-
-
Save jiridanek/8751879 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Cordova (cca): | |
// global variables | |
var data = null; | |
var port = 4242; | |
undefined | |
data = null; | |
chrome.socket.create('udp', function(s) { | |
port = port + 1; | |
console.log("s.socketId: " + s.socketId); | |
// listen | |
chrome.socket.bind(s.socketId, '0.0.0.0', port, function(t) { | |
console.log("t: " + t); | |
// notice the null for buf size | |
chrome.socket.recvFrom(s.socketId, null, function(u) { | |
console.log("recvFrom has data"); | |
data = u; | |
}); | |
}); | |
// send something? | |
b = new ArrayBuffer(1); | |
v = new Uint8Array(b); | |
v[0] = 42; | |
console.log(b); | |
// maybe not | |
//chrome.socket.sendTo(s.socketId, b, '127.0.0.1', port); | |
}); | |
s.socketId: 14 | |
ArrayBuffer {} | |
t: 0 | |
recvFrom has data | |
undefined | |
data | |
Object {resultCode: 0} | |
// expect data == null | |
console.log(data); | |
Object {resultCode: 0} | |
undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Chromium (actually Dartium): | |
// global variables | |
var data = null; | |
var port = 4242; | |
undefined | |
//test case, sort of | |
data = null; | |
chrome.socket.create('udp', function(s) { | |
port = port + 1; | |
console.log("s.socketId: " + s.socketId); | |
// listen | |
chrome.socket.bind(s.socketId, '0.0.0.0', port, function(t) { | |
console.log("t: " + t); | |
// notice the null for buf size | |
chrome.socket.recvFrom(s.socketId, null, function(u) { | |
console.log("recvFrom has data"); | |
data = u; | |
}); | |
}); | |
// send something? | |
b = new ArrayBuffer(1); | |
v = new Uint8Array(b); | |
v[0] = 42; | |
console.log(b); | |
// maybe not | |
//chrome.socket.sendTo(s.socketId, b, '127.0.0.1', port); | |
}); | |
undefined | |
s.socketId: 6 VM128:6 | |
ArrayBuffer {} VM128:20 | |
t: 0 VM128:9 | |
// expect data == null | |
console.log(data); | |
null VM129:3 | |
undefined |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
///////////////////////////////////////////// | |
// global variables | |
var data = null; | |
var port = 4242; | |
///////////////////////////////////////////// | |
//test case, sort of | |
data = null; | |
chrome.socket.create('udp', function(s) { | |
port = port + 1; | |
console.log("s.socketId: " + s.socketId); | |
// listen | |
chrome.socket.bind(s.socketId, '0.0.0.0', port, function(t) { | |
console.log("t: " + t); | |
// notice the null for buf size | |
chrome.socket.recvFrom(s.socketId, null, function(u) { | |
console.log("recvFrom has data"); | |
data = u; | |
}); | |
}); | |
// send something? | |
b = new ArrayBuffer(1); | |
v = new Uint8Array(b); | |
v[0] = 42; | |
console.log(b); | |
// maybe not | |
//chrome.socket.sendTo(s.socketId, b, '127.0.0.1', port); | |
}); | |
///////////////////////////////////////////// | |
// expect data == null | |
console.log(data); | |
///////////////////////////////////////////// |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment