Skip to content

How to stop uWS::Hub objects and subscription connections, #1649

@paddy709

Description

@paddy709

Code:
void MarketDataThread::Start(std::string channel, std::string symbol)
{
uWS::Hub hub;

hub.onMessage([&](uWS::WebSocket<uWS::CLIENT> *ws, char *message, size_t length, uWS::OpCode opCode)
               {
        // Handle incoming message from WebSocket
        std::string msg(message, length);

        std::cout << "Received message: " << msg << std::endl; });

hub.onConnection([&](uWS::WebSocket<uWS::CLIENT> *ws, uWS::HttpRequest req)
                  {
                      std::cout << "onConnection." << std::endl;
hub.onDisconnection([&](uWS::WebSocket<uWS::SERVER> *ws, int code, char *message, size_t length)
                    { 
                         std::cout << "onDisconnection." << std::endl;
                    });

// hub2.connect(*****, nullptr);


// 运行事件循环
hub.run();

}

void MarketDataThread::Stop()
{
// ???? HOW can I Do?
}

After I dynamically start the subscription in the thread, how do I stop the running of the uWS::Hub object in the stop? There is a uWS::Hub object in each thread. How do I implement it? thanks。

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions