Skip to content

Commit

Permalink
Fix firefox udp implementation.
Browse files Browse the repository at this point in the history
  • Loading branch information
Paul-E committed Jun 6, 2014
1 parent dc591ca commit 304174a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ module.exports = function(grunt) {
sourceMapIncludeSources: true,
mangle: false,
beautify: true,
compress: false,
preserveComments: function(node, comment) {
return comment.value.indexOf('jslint') !== 0;
},
Expand Down
20 changes: 10 additions & 10 deletions providers/udp_socket.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,15 +27,15 @@ Udp_firefox.prototype.getInfo = function(continuation) {
};

Udp_firefox.prototype.sendTo = function(buffer, address, port, continuation) {
// http://lxr.mozilla.org/mozilla-central/source/netwerk/base/public/nsINetAddr.idl
var nsINetAddr = {
family: Components.interfaces.nsINetAddr.FAMILY_INET,
port: port,
address: address
};
var bytesWritten = this._nsIUDPSocket.sendWithAddr(nsINetAddr,
buffer,
buffer.length);
var asArray = [];
var view = new Uint8Array(buffer);
for (var i = 0; i < buffer.byteLength; i++) {
asArray.push(view[i]);
}
var bytesWritten = this._nsIUDPSocket.send(address,
port,
asArray,
asArray.length);
continuation(bytesWritten);
};

Expand All @@ -53,7 +53,7 @@ nsIUDPSocketListener.prototype.onPacketReceived = function(nsIUDPSocket,
var eventData = {
resultCode: 0,
address: message.fromAddr.address,
port: message.fromAddr.address,
port: message.fromAddr.port,
data: this.str2ab(message.data)
};
this._udpSocket.dispatchEvent("onData",
Expand Down

0 comments on commit 304174a

Please sign in to comment.