Skip to content

Commit

Permalink
Re: #18 - Add error handling event handler to Examples/Program.cs.
Browse files Browse the repository at this point in the history
  • Loading branch information
bchavez committed Aug 19, 2020
1 parent c8a6495 commit 5db11a2
Showing 1 changed file with 15 additions and 1 deletion.
16 changes: 15 additions & 1 deletion Source/Examples/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using System.Linq;
using System;
using System.Linq;
using System.Net;
using System.Net.WebSockets;
using System.Threading;
Expand Down Expand Up @@ -86,6 +87,8 @@ public static async Task SubscribeToWebsocketEvents(Credentials creds)

WriteLine(">> Connected.");

socket.RawSocket.Closed += Websocket_Closed;
socket.RawSocket.Error += Websocket_Error;
socket.RawSocket.MessageReceived += Websocket_MessageReceived;

var sub = new Subscription
Expand All @@ -100,6 +103,17 @@ public static async Task SubscribeToWebsocketEvents(Credentials creds)
WriteLine(">> Subscribed.");
}

private static void Websocket_Closed(object sender, EventArgs e)
{
WriteLine("!! The websocket closed!");
}

private static void Websocket_Error(object sender, SuperSocket.ClientEngine.ErrorEventArgs e)
{
WriteLine("!! Websocket Error! ");
WriteLine(e);
}

private static void Websocket_MessageReceived(object sender, WebSocket4Net.MessageReceivedEventArgs e)
{
WriteLine("Message received.");
Expand Down

0 comments on commit 5db11a2

Please sign in to comment.