Skip to content
This repository has been archived by the owner on Jun 12, 2018. It is now read-only.

Create example on how to stream data to a client #82

Open
gocarlos opened this issue Aug 10, 2017 · 1 comment
Open

Create example on how to stream data to a client #82

gocarlos opened this issue Aug 10, 2017 · 1 comment

Comments

@gocarlos
Copy link

It would be great to have an example on how to send data from the server to a client in an asynchronous way.
I mean by that that the server should send data every couple of seconds to a connected client.

I could not figure out how this could be accomplished with the existing examples.
I think of calling something like that:

while (true) {
  auto send_stream = std::make_shared<WsServer::SendStream>();
  *send_stream << "mystring: " << asdfasf++;
  (*(ws_server->get_connections().begin()))->send(send_stream);
  sleep(2);
}

after that

  ws_server_thread = std::thread([&]() {
    ws_server->start();
    ws_server_started = true;
  });

Thanks in advance.

@eidheim
Copy link
Owner

eidheim commented Aug 11, 2017

Please see my recursive example in #74

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants