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

Stream of frames from server to client. #37

Open
erobledo opened this issue May 12, 2022 · 2 comments
Open

Stream of frames from server to client. #37

erobledo opened this issue May 12, 2022 · 2 comments

Comments

@erobledo
Copy link

I am trying to implement a one-way websocket endpoint that sends a never-ending stream of frames from the server to the client as soon as the connection is open and as soon as new data is available from some other part of the application.

I have searched through the oatpp websocket examples, and I have not found anything similar. All the examples seem to assume that the client initiates the communication, and all the frames sent from the server to the client are in "response" to a client frame.

It seems that server-initiated frames are not supported with the current oatpp-websocket framework. It looks like what I would need is to provide my own implementation of Task::run() inside oatpp::websocket::ConnectionHandler::handleConnection:

Is there any other way to achieve this? Or is this maybe a feature planned for the future?

@erobledo
Copy link
Author

Another way to achieve this kind of one-way stream would be to use the asynchronous API, and have an external thread send tasks to the appropriate Executor or Processor; the one running the corresponding AsyncWebSocket::Listener coroutine, I guess.

These tasks would simply call AsyncWebSocket::sendOneFrameAsync. But for that they would need to have access to the internal AsyncWebSocket object, and I can not find a way to get access to it.

@qcryptly
Copy link

Bad news, even having access to the AsyncWebSocket object doing sendOneFrameAsync doesn't seem to actually execute. Theres more stuff you have to do that I'm trying to figure out myself. There really is no point to having websockets if the server can't initiate a connection.

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