Swoole-src: Client Side Websocket example code?

Created on 21 Jan 2018  ·  4Comments  ·  Source: swoole/swoole-src

Hi,
is there somewhere an example for client side code when using swoole websockets please?
| Marc

question

All 4 comments

i see, so it is all php , no JS client

JS Client : https://github.com/swoole/swoole-src/blob/master/examples/websocket/client.html

var wsServer = 'ws://127.0.0.1:9501';
var websocket = new WebSocket(wsServer); 
websocket.onopen = function (evt) { 
    console.log("Connected to WebSocket server.");
}; 
websocket.onclose = function (evt) { 
    console.log("Disconnected"); 
}; 
websocket.onmessage = function (evt) { 
    console.log('Retrieved data from server: ' + evt.data); 
}; 
websocket.onerror = function (evt, e) {
    console.log('Error occured: ' + evt.data);
};

wao , awesome ! Thank you very much !

Was this page helpful?
0 / 5 - 0 ratings

Related issues

chenye2017 picture chenye2017  ·  3Comments

qifengzhang007 picture qifengzhang007  ·  3Comments

AndyChanCode picture AndyChanCode  ·  3Comments

rovico picture rovico  ·  4Comments

andreybolonin picture andreybolonin  ·  4Comments