Skip to content

Recieve data when using string literal, but fails when using variable #289

Open
@alexey-krukover

Description

@alexey-krukover

I have a socket server, where I print the message that I receive

When using this code, it works and the server prints 'test';

  int main() {
    sio::client h;
  
    h.connect("http://localhost:8000/device");
    h.set_socket_open_listener(std::bind([&]() {
        h.socket("device")->emit("init", {"test"});
    })
  }

But when I us this code, I get empty message;

  int main() {
    sio::client h;
    string msg = "test";
  
    h.connect("http://localhost:8000/device");
    h.set_socket_open_listener(std::bind([&]() {
        h.socket("device")->emit("init", {msg});
    })
  }

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions