-
-
Notifications
You must be signed in to change notification settings - Fork 2k
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
How can one bind the receive and send of the server to istream and ostream #979
Comments
The WebSocket protocol is a message based protocol. WebSocket++ presents this protocol to the client application using the send method for outgoing and the message handler callback for incoming messages. This is the only interface. WebSocket++ can read and write the encoded byte stream to a few different locations, including iostreams. Calling the send method in this case results in the framed and encoded messages being written to an ostream instead of a network socket. Similarly, if you have an encoded WebSocket protocol stream, WebSocket++ can read the raw bytes from an istream and will call the message handler once for every message decoded from the stream. |
@zaphoyd Thanks. I've been using Scala for years now and stream abstractions there give you the opportunity to build streams of messages. So one can add messages to an outgoing stream or receive from an incoming one. In this case, I was wondering if one can implement two stream-buffers that one keep pulling in messages as they come and one keep pushing them out as they come. This way one might be able to create one |
If you are talking about the entire WebSocket byte stream you can do that out of the box with the iostream transport. The bundled This can be used to do things like play back a recorded WebSocket byte stream captured with wireshark, performance testing, automated test suites, etc. You seem to be talking more about doing this at the application data level though. You can definitely write If you just want a program that reads data on standard in and pushes it out to the websocket and vice versa with standard out that doesn't need any special iostream wrappers. It is sufficient to have a message handler that writes to std::cout (or whatever stream you want) and another thread (or some other async/non-blocking stream read) that sits on standard in and calls |
Hi,
Thanks for this lib.
Is it possible to create an
istream
andostream
from the server and use them instead ofset_message_handler
andsend
? I saw some examples but they were not what I was looking for. I want to be able to get ani/o stream
from the server and pass it through another function.Thanks
The text was updated successfully, but these errors were encountered: