Skip to content

Commit

Permalink
Added I/O exception handling to WebSocketGateway.cs
Browse files Browse the repository at this point in the history
  • Loading branch information
genemars committed Jan 4, 2023
1 parent a8add87 commit 4232c1b
Showing 1 changed file with 13 additions and 7 deletions.
20 changes: 13 additions & 7 deletions MIG/Gateways/WebSocketGateway.cs
Original file line number Diff line number Diff line change
Expand Up @@ -115,16 +115,22 @@ public void OnInterfacePropertyChanged(object sender, InterfacePropertyChangedEv
WebSocketServiceHost host;
webSocketServer.WebSocketServices.TryGetServiceHost("/events", out host);
if (host == null) return;

if (messagePack)
try
{
//var lz4Options = MessagePackSerializerOptions.Standard.WithCompression(MessagePackCompression.Lz4BlockArray);
//byte[] eventBytes = MessagePackSerializer.Serialize(args.EventData, lz4Options);
host.Sessions.BroadcastAsync(MigService.Pack(args.EventData), () => {});
if (messagePack)
{
//var lz4Options = MessagePackSerializerOptions.Standard.WithCompression(MessagePackCompression.Lz4BlockArray);
//byte[] eventBytes = MessagePackSerializer.Serialize(args.EventData, lz4Options);
host.Sessions.BroadcastAsync(MigService.Pack(args.EventData), () => { });
}
else
{
host.Sessions.BroadcastAsync(MigService.JsonSerialize(args.EventData), () => { });
}
}
else
catch (Exception e)
{
host.Sessions.BroadcastAsync(MigService.JsonSerialize(args.EventData), () => {});
MigService.Log.Error(e);
}
}
}
Expand Down

0 comments on commit 4232c1b

Please sign in to comment.