private void SocketEvent_ProcessMessage(object sender, SocketEventArgs data) { if (!SocketEvent_InSync) { SocketEvent_InSync = true; this.Queue(false, new Action(() => SocketEvent_InSyncEvent?.Invoke(this, true))); } switch (data.Command) { case 1: //Initial Scan this.Queue(false, new Action(() => HealthCheck?.Invoke(sender, new HealthCheckEventArgs(data.ID)))); HealthCheckEventArgs hc = new HealthCheckEventArgs(data.ID); hc.Valid = flipflop; flipflop ^= true; HealthCheckResponse(hc); break; case 10: //Tote ready for pickup. this.Queue(false, new Action(() => ToteReady?.Invoke(sender, data))); break; case 12: //Tote Loading complete. this.Queue(false, new Action(() => ToteLoadComplete?.Invoke(sender, data))); break; case 13: //Tote Unloading complete. this.Queue(false, new Action(() => ToteUnloadComplete?.Invoke(sender, data))); break; } }
private void SocketEvent_ClientCleanup() { SocketEvent_ProcessMessageEvent -= SocketEvent_ProcessMessage; if (SocketEvent_InSync) { SocketEvent_InSync = false; SocketEvent_InSyncEvent?.Invoke(this, false); } if (SocketEvent_Client == null) { return; } SocketEvent_Client?.Close(); SocketEvent_Client?.Dispose(); SocketEvent_Client = null; }