private void IotServer_ClientConnected(IIOTServer server, IIOTClient client) { client.MessageReceived += Client_MessageReceived; client.ErrorOccured += Client_ErrorOccured; client.Disconnected += Client_Disconnected; Dispatch(() => { clients.Add(client, new IOTClientUIInfo() { LastResponseTime = DateTime.Now }); SendMessageSafe(client, new IOTMessage(CreateSirenOnParameter(), new string[] { statusQuery })); IsConnected = clients.Count > 0; AddEvent("New Connection " + client.RemoteAddress.ToString(), EventType.NewConnection); }); }
public MainViewModel(CoreDispatcher dispatcher, IIOTServer iotServer, IAudioPlayer audioPlayer) { this.iotServer = iotServer; this.audioPlayer = audioPlayer; this.dispatcher = dispatcher; Events = new ObservableCollection <EventModel>(); AlarmTriggerEvents = new ObservableCollection <EventModel>(); Rssi = new SensorValueModel("rssi"); Rssi.DisableUIColor = true; DisconnectCount = new SensorValueModel("disconnect count"); DisconnectCount.DisableUIColor = true; DisconnectCount.Update(0); Sector0 = new SensorValueModel("sector0", false, TriggerAlarm); Movement0 = new SensorValueModel("movement0", true, TriggerAlarm); Parameters = new List <SensorValueModel> { Rssi, Sector0, Movement0 }; AlarmTriggers = new List <SensorValueModel> { Sector0, Movement0 }; StopAlarmCommand = new UICommand(StopAlarmSound, false); AlarmToggleCommand = new UICommand(AlarmToggleAction, true); StatusQueryCommand = new UICommand(QueryAllClientsStatus, false); CloseAllConnectionsCommand = new UICommand(CloseAllConnections, false); ToggleSirenCommand = new UICommand(ToggleSiren, false); }