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

WebSocket client #1051

Closed
WebFreak001 opened this issue Mar 31, 2015 · 12 comments
Closed

WebSocket client #1051

WebFreak001 opened this issue Mar 31, 2015 · 12 comments

Comments

@WebFreak001
Copy link
Contributor

It would be nice if there would be an WebSocket client for connecting to externals servers and redirecting that output to the user and process it on the server.

@dariusc93
Copy link
Contributor

@WebFreak001 you mean like for the client-side (eg javascript) or a vibe.d websocket client that connects to another server that has websockets?

@WebFreak001
Copy link
Contributor Author

No I want the vibe.d server to connect to a websocket server. There is also TCPclient so why not WebSocket client

@dariusc93
Copy link
Contributor

@WebFreak001 well websocket was not made for server-to-server connection. It shouldnt be to hard to implement but to me honestly do not see the point. maybe @s-ludwig could talk explain?

Also could you explain what youre trying to do? Maybe there is a different solution. I honest feel that the websocket should be slighly rewritten.

@WebFreak001
Copy link
Contributor Author

I want to make a chat bot for hitbox (which uses websockets). I used nodejs before but now i switched to vibe.d because not having actual classes in javascript (Not prototype stuff, JSON or new Function) is really annoying. (I tried TypeScript but the compiler is bugged and now I really hate it and I dont like coffeescript or dart)

@s-ludwig
Copy link
Member

s-ludwig commented Apr 1, 2015

This would be relatively straight forward to do, mostly reusing the existing code. I can't personally promise a date when I would have the time to actually implement and test it, though.

@dariusc93
Copy link
Contributor

@WebFreak001 is the websockets are for javascript for client-side to talk to the server and youre trying to talk to another server at the same time, you could look into using the rest interface. I use the rest interface to send data back and forth between the servers (I would use tcp for that but i decided to just use rest for now). Like @s-ludwig said, it should be straight forward. I dont think it should be to hard to do though, but I moved to vibe.d because I did get tired of node.js. I normally try to stick with system languages like go, d, rust, c/c++.

@etcimon
Copy link
Contributor

etcimon commented Apr 1, 2015

The client basically does the inverse of the server negotiation: https://github.com/rejectedsoftware/vibe.d/blob/master/source/vibe/http/websockets.d#L69

I would suggest to follow the RFC.

As for the Websocket class and all the rest, I don't think there's any difference. Probably a 100 lines of code missing there.

@s-ludwig
Copy link
Member

s-ludwig commented Apr 1, 2015

If not even much less!

@etcimon
Copy link
Contributor

etcimon commented Apr 1, 2015

The only particularities I can see is this

Clients MUST choose a new masking key for each frame
(the data from the server to the client is not masked).

WebSocket clients verify that the server included one of the values that was specified in the WebSocket client's handshake.

@etcimon
Copy link
Contributor

etcimon commented Apr 1, 2015

Usage would look like this:

void handler(scope WebSocket ws) { .. }

requestHTTP("http://....", (scope req) { handleWebsocket(&handler, req); });

The HTTPClientRequest will need a switchProtocol

@yannick
Copy link
Contributor

yannick commented Apr 12, 2015

would be great to have this in.
this could also be useful to build a rpc system over websocket e.g. with msgpack-d

@WebFreak001
Copy link
Contributor Author

Just found out about connectWebSocket, seems to be implemented already

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

5 participants