oatpp/example-websocket

WS Connection should be fully established by the time WSInstanceListener::onAfterCreate method is called.

TimeStealsEverything opened this issue · 2 comments

void WSInstanceListener::onAfterCreate(const oatpp::websocket::WebSocket& socket, const std::shared_ptr<const ParameterMap>& params) {

  SOCKETS ++;
  OATPP_LOGD(TAG, "New Incoming Connection. Connection count=%d", SOCKETS.load());

  /* In this particular case we create one WSListener per each connection */
  /* Which may be redundant in many cases */
  socket.setListener(std::make_shared<WSListener>());

  std::thread t([&socket]{
    socket.sendOneFrameText("Hello");
  });

  t.detach();

}

WS Connection should be fully established by the time WSInstanceListener::onAfterCreate method is called.