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; public int MaxRooms;
private static readonly Logger _logger = LogManager.GetCurrentClassLogger(); 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() private static void CopyrightInfo()
{ {
+4
View File
@@ -27,6 +27,8 @@ namespace Ragon.Core
public void Start(ushort port, int connections, uint protocol) public void Start(ushort port, int connections, uint protocol)
{ {
Library.Initialize();
_address = default; _address = default;
_address.Port = port; _address.Port = port;
_peers = new Peer[connections]; _peers = new Peer[connections];
@@ -146,6 +148,8 @@ namespace Ragon.Core
public void Stop() public void Stop()
{ {
_host?.Dispose(); _host?.Dispose();
Library.Deinitialize();
} }
private bool IsValidProtocol(uint protocol) private bool IsValidProtocol(uint protocol)
+8 -1
View File
@@ -75,7 +75,14 @@ public class WebSocketServer : ISocketServer
{ {
if (_webSockets.TryGetValue(evnt.PeerId, out var ws) && ws.State == WebSocketState.Open) if (_webSockets.TryGetValue(evnt.PeerId, out var ws) && ws.State == WebSocketState.Open)
{ {
await ws.SendAsync(evnt.Data, WebSocketMessageType.Binary, WebSocketMessageFlags.EndOfMessage, CancellationToken.None); try
{
await ws.SendAsync(evnt.Data, WebSocketMessageType.Binary, WebSocketMessageFlags.EndOfMessage, CancellationToken.None);
}
catch (Exception ex)
{
_logger.Error(ex);
}
} }
} }
} }