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

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

@gocarlos

Description

@gocarlos

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions