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

Are query parameters supported? #45

Open
rcoenen opened this issue May 5, 2017 · 1 comment
Open

Are query parameters supported? #45

rcoenen opened this issue May 5, 2017 · 1 comment

Comments

@rcoenen
Copy link

rcoenen commented May 5, 2017

The WebSocket specification states that this is a valid websocket URI:
ws://myserver.com/path?param=1

However I am unsure if nodejs-websocket supports access to the URI parameters.

Can anyone tell me if this is supported (and if yes, how to use it)?

Thanks

@hlev
Copy link

hlev commented Jun 10, 2017

The Connection is passed as parameter to the "connection" listener, so you could do:

var ws = require("nodejs-websocket");

var server = ws.createServer(function (conn) {
	console.log(conn.path); // /path?param=1
	
        // ...
}).listen(8001)

But as far as I looked at the source, you would have to process the string yourself, there are no utility methods in the library itself.

You could use the querystring module of node's to parse the parameters after splitting the path on ?

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