Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Question] As a server usage or how to pass PORT to listen to? #25

Closed
ArturJS opened this issue Mar 1, 2020 · 2 comments
Closed

[Question] As a server usage or how to pass PORT to listen to? #25

ArturJS opened this issue Mar 1, 2020 · 2 comments

Comments

@ArturJS
Copy link

ArturJS commented Mar 1, 2020

Hello @vitalets,

Just out of curiosity, is it possible to use websocket-as-promised as a websocket server akin to ws module?

For example:
https://github.com/websockets/ws#simple-server

const WebSocket = require('ws');
const wss = new WebSocket.Server({ port: 8080 });

wss.on('connection', function connection(ws) {
  ws.on('message', function incoming(message) {
    console.log('received: %s', message);
  });
  ws.send('something');
});

If it's not can I submit PR that will introduce this functionality?
Thanks!

@vitalets
Copy link
Owner

vitalets commented Mar 2, 2020

hi @ArturJS
websocket-as-promised is intended to be a client, not server. Because in case of server, it's not clear what should be promisified. Your example with ws looks nice to me.
You can use any websocket server library for websocket-as-promised client.

@ArturJS
Copy link
Author

ArturJS commented Mar 2, 2020

@vitalets hmm, interesting...
Thanks for the information!
Just didn't know that it's a client only library.
Closing as resolved.

@ArturJS ArturJS closed this as completed Mar 2, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants