Last active
December 20, 2015 05:18
-
-
Save kruyvanna/6076754 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
window.App.webSocketServer = {}; | |
var PORT = 3001; | |
var socketServer = new monaca.WebSocketServer(PORT); | |
socketServer.onClientConnected = function(client){ | |
App.trigger('client:connected', client); | |
}; | |
socketServer.onClientDisconnected = function(client){ | |
App.trigger('client:disconnected', client); | |
}; | |
socketServer.onerror = function(error){ | |
echo(error); | |
}; | |
App.webSocketServer.start = function(){ | |
socketServer.start( | |
function(response){ | |
App.trigger('websocket_server:started', response); | |
}, | |
echo | |
); | |
} | |
App.webSocketServer.getClients = function(success, failure){ | |
socketServer.getClients( | |
success, | |
failure | |
); | |
} | |
App.webSocketServer.sendMessageToClients = function(message){ | |
socketServer.sendToAllClients( | |
message, | |
echo, | |
echo | |
); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment