Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Method for connect to server please specify your IP in Websocket constructur
- function WebSocketTest()
- {
- if ("WebSocket" in window)
- {
- alert("WebSocket is supported by your Browser!");
- // Let us open a web socket
- *var ws = new WebSocket("ws://www.google.co.in/");*
- ws.onopen = function()
- {
- // Web Socket is connected, send data using send()
- ws.send("{"sessionId":"1","message":"hi google"}");
- alert("Message is sent...");
- };
- ws.onmessage = function (evt)
- {
- var received_msg = evt.data;
- alert("Message is received..."+received_msg);
- };
- ws.onclose = function()
- {
- // websocket is closed.
- alert("Connection is closed...");
- };
- }
- else
- {
- // The browser doesn't support WebSocket
- alert("WebSocket NOT supported by your Browser!");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement