public bool Send(XComm.Sample.Message _Data) { _Message = _Data; Formatter.Serialize(Stream_Network, _Message); _Message = (XComm.Sample.Message)Formatter.Deserialize(Stream_Network); /* if (_Message.UserName == "Ok") * { * return true; * }*/ return(false); }
private void RespondClientRequest() { NetworkStream Stream_network; try { Stream_network = Socket_Client.GetStream(); while (Socket_Client.Connected == true && _StopServer == false) { _Message = (XComm.Sample.Message)Formatter.Deserialize(Stream_network); //////////////////////////////////////////////////////////////////////////////// _Delegate.Invoke(_Message); /* if (_Message.UserName == "Jay") * { * _Message.UserName = "******"; * Formatter.Serialize(Stream_network, _Message); * } * else * { * _Message.UserName = "******";*/ Formatter.Serialize(Stream_network, _Message); //} //////////////////////////////////////////////////////////////////////////////// } } catch (System.Exception) { //throw; } }
private void data_Rec(XComm.Sample.Message Data) { try { this.ZoneId = Data.ZoneId; this.ZoneName = Data.ZoneName; LocationCollection temp_locationCollection = new LocationCollection(); for (int i = 0; i < Data.ZoneLocation.Count; i++) { Location temp = new Location(Data.ZoneLocation[i].Latitude, Data.ZoneLocation[i].Longitude); temp_locationCollection.Add(temp); } ZoneLocation = temp_locationCollection; this.Temperature = Data.Temperature; this.Pressure = Data.Pressure; this.Humidity = Data.Humidity; this.FireStatus = Data.FireStatus; this.Fire_Location = new Location(Data.Fire_Location.Latitude, Data.Fire_Location.Longitude); this.Rain1_Status = Data.Rain1_Status; LocationCollection temp_locationCollection1 = new LocationCollection(); for (int i = 0; i < Data.Rain1_Location.Count; i++) { Location temp = new Location(Data.Rain1_Location[i].Latitude, Data.Rain1_Location[i].Longitude); temp_locationCollection1.Add(temp); } Rain1_Location = temp_locationCollection1; //this.Rain1_Location = Data.Rain1_Location; this.Rain2_Status = Data.Rain2_Status; LocationCollection temp_locationCollection2 = new LocationCollection(); for (int i = 0; i < Data.Rain2_Location.Count; i++) { Location temp = new Location(Data.Rain2_Location[i].Latitude, Data.Rain2_Location[i].Longitude); temp_locationCollection2.Add(temp); } Rain2_Location = temp_locationCollection2; //this.Rain2_Location = Data.Rain2_Location; zone1_name.Dispatcher.BeginInvoke((Action) delegate { zone1_name.Content = ZoneName; }); lbl_temp.Dispatcher.BeginInvoke((Action) delegate { lbl_temp.Content = Temperature; }); lbl_pressure.Dispatcher.BeginInvoke((Action) delegate { lbl_pressure.Content = Pressure; }); lbl_humidity.Dispatcher.BeginInvoke((Action) delegate { lbl_humidity.Content = Humidity; }); myMap.Dispatcher.BeginInvoke((Action) delegate { // for drawing zone area NewMap.addNewPolyline(ZoneLocation); //for zone 1 fire if (Data.FireStatus == true && flag_task == false) { if (flag_task == false) { //task_fire.Start(); } NewMap.AddLabel(Fire_Location, "fire"); NewMap.AddPushpin(Fire_Location); } else if (flag_task == true) { simpleSound.Stop(); flag_task = false; } //for zone 1 rain if (Data.Rain1_Status == true) { NewMap.addNewPolygon(Rain1_Location); } if (Data.Rain2_Status == true) { NewMap.addNewPolygon(Rain2_Location); } //------------------------------------------------------------------------------------------------- myMap.Children.Clear(); //------------------------------------------------------------------------------------------------ if (Data.Rain1_Status == true) { NewMap.addNewPolygon(Rain1_Location); } if (Data.Rain2_Status == true) { NewMap.addNewPolygon(Rain2_Location); } NewMap.addNewPolyline(ZoneLocation); if (Data.FireStatus == true) { NewMap.AddLabel(Fire_Location, "fire"); NewMap.AddPushpin(Fire_Location); } }); } catch (Exception ex) { } Thread.Sleep(1000); }