public Pi2GoWebSocketServer(IPi2GoLiteRobot robot, int port, IImageCapture imageCapture = null, TextWriter traceWriter = null) { state = new Pi2GoLiteState(); webSocket = new WebSocketSharp.Server.WebSocketServer(port); webSocket.AddWebSocketService(pathOperations, () => new WebSocketOperationMessageReceiver(robot, state) { TraceWriter = traceWriter }); if (imageCapture != null) { webSocket.AddWebSocketService(pathImages, () => new WebSocketImageMessageSender(imageCapture)); } webSocket.Start(); }
static void Main(string[] args) { try { // direct control //robot = BuildLocalRobot(); // remote control via web socket robot = BuildRemoteRobot(); robot.Setup(); ManualControl(); } finally { if (robot != null) { robot.Dispose(); } } Console.WriteLine("done."); }
internal WebSocketOperationMessageReceiver(IPi2GoLiteRobot robot, Pi2GoLiteState state) { this.robot = robot; this.state = state; }