Skip to content

Immidiatle server responce #11

@GlebKit

Description

@GlebKit

Hi. I'm trying to reimplement server logic from Flask to oat++ and have stopped at a problem with server response. I need the server to send a response after the WebSocket has been established. I tried to do it here:
cpp

void WSInstanceListener::onAfterCreate_NonBlocking(const std::shared_ptrWSListener::AsyncWebSocket& socket, const std::shared_ptr& params) {
SOCKETS++;
oatpp::String deviceId;

if (params && params->find("device_id") != params->end()) {
    deviceId = params->at("device_id");
} else {
    deviceId = "";
}
socket->setListener(std::make_shared<WSListener>(deviceId, socket));
OATPP_LOGd(TAG, "New Incoming Connection. Connection count={}", SOCKETS.load());
socket->sendOneFrameTextAsync("Server resp "); // <---------- HERE

}

But it doesn't send anything. Is it possible to do this somewhere else? Or is it possible to set a one-time callback to send the response?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions