I am using the SuperSocket.WebSocket NuGet package version 1.6.6.1.
The following code:
var sessions = _webSocketServer.GetAllSessions().ToList();
_webSocketServer.Broadcast(sessions, serializedMessage, (session, sendOk) =>
{
if (!sendOk)
{
try
{
session.Send(serializedMessage);
}
catch
{
PolicyHelper.TryOnce(() => session.Close(CloseReason.SocketError));
}
}
});
sometimes throws NullReferenceException.
Also, could you please tell me if I am using the sendFeedback parameter correctly? I want to make sure that the message is broadcast, so if sendOk is false then I just manually call the session.Send(serializedMessage) method to make sure it will get send (I have observed cases when the sendOk was false and the WebSocketSession was connected and healthy).
I just want to make sure that the message will be broadcast to all clients, so I have to check the sendOk param. Wouldn't it be better if WebSocketServer.Broadcast internally used a new method
void WebSocketSession<TWebSocketSession>.SendRawData(IList<ArraySegment<byte>> segments)
instead of the current
bool WebSocketSession<TWebSocketSession>.TrySendRawData(IList<ArraySegment<byte>> segments)?
I am using the SuperSocket.WebSocket NuGet package version 1.6.6.1.
The following code:
sometimes throws
NullReferenceException.Also, could you please tell me if I am using the sendFeedback parameter correctly? I want to make sure that the message is broadcast, so if
sendOkisfalsethen I just manually call thesession.Send(serializedMessage)method to make sure it will get send (I have observed cases when thesendOkwasfalseand the WebSocketSession was connected and healthy).I just want to make sure that the message will be broadcast to all clients, so I have to check the
sendOkparam. Wouldn't it be better ifWebSocketServer.Broadcastinternally used a new methodvoid WebSocketSession<TWebSocketSession>.SendRawData(IList<ArraySegment<byte>> segments)instead of the current
bool WebSocketSession<TWebSocketSession>.TrySendRawData(IList<ArraySegment<byte>> segments)?