ClusterWS-Client-JS icon indicating copy to clipboard operation
ClusterWS-Client-JS copied to clipboard

a clusterWS-Client-JS implementation for uWebSockets Server

Open pannet1 opened this issue 5 years ago • 0 comments

Submitting

  • [ ] Bug
  • [ x] Question
  • [ ] Suggestion
  • [ ] Other

Details

Is there any example of clusterWS-Client-JS implementation for uWebSockets Server. I have basically invested some time on python server side tasks and want to read some data pushed by the websocket ###python server (not yet implemented). `import uws import asyncio from time import time

Integrate with asyncio asyncio.set_event_loop(uws.Loop())

app = uws.App({ "some": "option" })

def getHandler(res, req): res.end("Hello Python!")

app.get("/*", getHandler)

def listenHandler(): print(time())

app.listen("ws://localhost", 3000, listenHandler)

Run asyncio event loop asyncio.get_event_loop().run_forever()`

#client (to be changed into standalone browser script) `const { WebSocket } = require('@clusterws/cws'); const socket = new WebSocket('ws://localhost:3000');

socket.on('open', () => { console.log('opened')
});

socket.on('message', (message) => { console.log(message) });

socket.on('error', (err) => { console.log() });`

###the expected work flow is as below

browser->server->login() server->browser->success() browser->server->subscribe(data) server->browser->message()

pannet1 avatar May 10 '20 10:05 pannet1