diff --git a/ixwebsocket/IXWebSocketServer.cpp b/ixwebsocket/IXWebSocketServer.cpp index 78aaf8f6..bef87c4a 100644 --- a/ixwebsocket/IXWebSocketServer.cpp +++ b/ixwebsocket/IXWebSocketServer.cpp @@ -97,9 +97,10 @@ namespace ix } else if (_onClientMessageCallback) { + WebSocket* webSocketRawPtr = webSocket.get(); webSocket->setOnMessageCallback( - [this, &ws = *webSocket.get(), connectionState](const WebSocketMessagePtr& msg) { - _onClientMessageCallback(connectionState, ws, msg); + [this, webSocketRawPtr, connectionState](const WebSocketMessagePtr& msg) { + _onClientMessageCallback(connectionState, *webSocketRawPtr, msg); }); } else