Created
April 5, 2012 14:20
-
-
Save ndeverge/2311387 to your computer and use it in GitHub Desktop.
client side websocket
This file contains hidden or 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
var WS = window['MozWebSocket'] ? MozWebSocket : WebSocket | |
var mapSocket = new WS("@routes.Application.mapsocket().webSocketURL(request)"); | |
mapSocket.onmessage = function(event) { | |
var data = JSON.parse(event.data); | |
marker = moveMaker(map, marker, data.longitude, data.latitude); | |
} | |
// if errors on websocket | |
var onalert = function(event) { | |
$(".alert").removeClass("hide"); | |
} | |
mapSocket.onerror = onalert; | |
mapSocket.onclose = onalert; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment