From cbbd24f5f75aca02897c92e6a4e85210af7a2056 Mon Sep 17 00:00:00 2001 From: Stefan Schreistetter Date: Tue, 20 Aug 2019 17:59:20 +0200 Subject: [PATCH] Fixed problem where behavior was not correctly instantiated. Added null checking for sessions. --- GazeWebSocketServer/GazeCoordinateBehavior.cs | 2 +- GazeWebSocketServer/Program.cs | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/GazeWebSocketServer/GazeCoordinateBehavior.cs b/GazeWebSocketServer/GazeCoordinateBehavior.cs index 621366a..bce48af 100644 --- a/GazeWebSocketServer/GazeCoordinateBehavior.cs +++ b/GazeWebSocketServer/GazeCoordinateBehavior.cs @@ -30,7 +30,7 @@ namespace GazeWebSocketServer internal void Publish(GazeData gazeData) { - Sessions.Broadcast(gazeData.ToString()); + Sessions?.Broadcast(gazeData.ToString()); } } } diff --git a/GazeWebSocketServer/Program.cs b/GazeWebSocketServer/Program.cs index 8ccad82..2c5b41e 100644 --- a/GazeWebSocketServer/Program.cs +++ b/GazeWebSocketServer/Program.cs @@ -9,8 +9,9 @@ namespace GazeWebSocketServer { public static void Main(string[] args) { - var wssv = new WebSocketServer("ws://localhost:8001"); - wssv.AddWebSocketService("/gaze", () => new GazeCoordinateBehavior()); + var wssv = new WebSocketServer(8001); + GazeCoordinateBehavior behavior = new GazeCoordinateBehavior(); + wssv.AddWebSocketService("/gaze", () => behavior); wssv.Start(); Console.ReadKey(true); -- libgit2 0.26.0