Compare commits

...

2 Commits

Author SHA1 Message Date
edmand46 e2ef761bd7 fixed: windows server 2022-12-15 23:55:59 +04:00
edmand46 828112855f fixed: crash on send in websocket server 2022-12-04 23:01:05 +04:00
3 changed files with 13 additions and 2 deletions
+1 -1
View File
@@ -21,7 +21,7 @@ namespace Ragon.Core
public int MaxRooms;
private static readonly Logger _logger = LogManager.GetCurrentClassLogger();
private static readonly string _serverVersion = "1.0.26-rc";
private static readonly string _serverVersion = "1.0.27-rc";
private static void CopyrightInfo()
{
+4
View File
@@ -27,6 +27,8 @@ namespace Ragon.Core
public void Start(ushort port, int connections, uint protocol)
{
Library.Initialize();
_address = default;
_address.Port = port;
_peers = new Peer[connections];
@@ -146,6 +148,8 @@ namespace Ragon.Core
public void Stop()
{
_host?.Dispose();
Library.Deinitialize();
}
private bool IsValidProtocol(uint protocol)
@@ -74,9 +74,16 @@ public class WebSocketServer : ISocketServer
while (_events.TryDequeue(out var evnt))
{
if (_webSockets.TryGetValue(evnt.PeerId, out var ws) && ws.State == WebSocketState.Open)
{
try
{
await ws.SendAsync(evnt.Data, WebSocketMessageType.Binary, WebSocketMessageFlags.EndOfMessage, CancellationToken.None);
}
catch (Exception ex)
{
_logger.Error(ex);
}
}
}
}