Hi @m_adam,
thank you again for the code suggestions, I got it compiling and running now, but now I do have a runtime failure, I am trying to test the websocket connection with postman, and I get a 500 error, the logs of Cinema 4D say this:
<net.maxon.datatype.internedid> net.maxon.http.type : <uint32> 1
<net.maxon.datatype.internedid> net.maxon.http.file : <net.maxon.interface.string-C> index.html
<net.maxon.interface.string-C> sec-websocket-extensions : <net.maxon.interface.string-C> permessage-deflate; client_max_window_bits
<net.maxon.interface.string-C> sec-websocket-version : <net.maxon.interface.string-C> 13
<net.maxon.interface.string-C> sec-websocket-key : <net.maxon.interface.string-C> j+y86BlBpKXcFzGDp/BOXg==
<net.maxon.interface.string-C> host : <net.maxon.interface.string-C> localhost:19923
<net.maxon.datatype.internedid> net.maxon.http.connection : <net.maxon.interface.string-C> Upgrade
<net.maxon.interface.string-C> upgrade : <net.maxon.interface.string-C> websocket
protocol not found
Connection: Stopped with error httpcode [network_websocket_base_impl.cpp(556)]
Cause: websocket protocol not found [network_websocket_base_impl.cpp(646)].
httpcode [network_websocket_base_impl.cpp(556)]
Cause: websocket protocol not found [network_websocket_base_impl.cpp(646)]
This is my current websocket implementation:
WebSocket::WebSocket(int port)
: mPort(port)
{
}
WebSocket::~WebSocket()
{
maxon::Result<void> res = mWebSocketServer.StopWebServer();
if (res.GetErrorPointer() != nullptr)
{
ApplicationOutput("Failed to shutdown the websocket!");
}
}
maxon::Result<void> WebSocket::Start()
{
iferr_scope;
maxon::NetworkIpAddrPort addr(127, 0, 0, 1, mPort);
mWebSocketServer = maxon::NetworkWebSocketServerClass().Create() iferr_return;
WebSocket* instance = this;
mWebSocketServer.ObservableConnected(true).AddObserver(
[instance](const maxon::NetworkWebSocketConnectionRef& webSocket, const maxon::DataDictionary& request) -> maxon::Result<void>
{
return instance->OnConnected(webSocket, request);
}) iferr_return;
mWebSocketServer.ObservableDisconnected(true).AddObserver(
[instance](const maxon::NetworkWebSocketConnectionRef& webSocket) -> void
{
instance->OnDisconnected(webSocket);
}) iferr_return;
mWebSocketServer.ObservableHandshake(true).AddObserver(
[instance](const maxon::NetworkWebSocketConnectionRef& webSocket, const maxon::DataDictionary& request) -> maxon::Result<String>
{
return instance->OnHandShake(webSocket, request);
}) iferr_return;
mWebSocketServer.ObservableMessage(true).AddObserver(
[instance](const maxon::NetworkWebSocketConnectionRef& webSocket, maxon::WEBSOCKET_OPCODE opCode, const maxon::BaseArray<Char>& data) -> maxon::Result<void>
{
return instance->OnMessage(webSocket, opCode, data);
}) iferr_return;
mWebSocketServer.StartWebServer(addr, false, "<tried different values here but no change>"_s) iferr_return;
return maxon::OK;
}
maxon::Result<void> WebSocket::OnConnected(const maxon::NetworkWebSocketConnectionRef& webSocket, const maxon::DataDictionary& request)
{
iferr_scope;
return maxon::OK;
}
void WebSocket::OnDisconnected(const maxon::NetworkWebSocketConnectionRef& webSocket)
{
iferr_scope_handler
{
return;
};
}
maxon::Result<String> WebSocket::OnHandShake(const maxon::NetworkWebSocketConnectionRef& webSocket, const maxon::DataDictionary& request)
{
iferr_scope;
return ""_s;
}
maxon::Result<void> WebSocket::OnMessage(const maxon::NetworkWebSocketConnectionRef& webSocket, maxon::WEBSOCKET_OPCODE opCode, const maxon::BaseArray<Char>& data)
{
iferr_scope;
return maxon::OK;
}
Do you know, what could cause this error? Thank you very much for your help already!