Commit ad2c966f authored by 's avatar

Update websocket-server to use chrome.sockets API.

The chrome.socket API is deprecated since Chrome 33.
parent ccbc1ab8
This diff is collapsed.
......@@ -64,12 +64,12 @@ if (http.Server && http.WebSocketServer) {
wsServer.addEventListener('request', function(req) {
var socket = req.accept();
socket_dict[socket.socketId_] = {
socket_dict[socket.pSocket_.socketId] = {
socket: socket
};
chrome.socket.getInfo(socket.socketId_, function (result) {
chrome.sockets.tcp.getInfo(socket.pSocket_.socketId, function (result) {
if ((result !== undefined) && (result.connected)) {
socket_dict[socket.socketId_].peer = result.peerAddress + ':' + result.peerPort;
socket_dict[socket.pSocket_.socketId].peer = result.peerAddress + ':' + result.peerPort;
updateStatus(socket_dict);
}
});
......@@ -87,7 +87,7 @@ if (http.Server && http.WebSocketServer) {
// When a socket is closed, remove it from the list of connected sockets.
socket.addEventListener('close', function() {
delete socket_dict[socket.socketId_];
delete socket_dict[socket.pSocket_.socketId];
updateStatus(socket_dict);
});
return true;
......
......@@ -6,10 +6,17 @@
"minimum_chrome_version": "44",
"offline_enabled": true,
"manifest_version": 2,
"permissions": ["system.network", {
"socket": [
"tcp-connect",
"tcp-listen"]}],
"permissions": ["system.network"],
"sockets": {
"tcp": {
"connect": "*"
},
"tcpServer": {
"listen": "*"
}
},
"app": {
"background": {
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment