private void stopMess(StopSrvMessage mess) { try { status = string.Format("[{0}]公告服务器停止({1}:{2})", DateTime.Now.ToLocalTime(), this.client.ServerPoint.Address.ToString(), this.client.ServerPoint.Port); if (this.client != null) { this.client.Close(false); } } catch (Exception exception) { this.log.ErrorFormat("接收服务器停止信息异常:{0}", exception.ToString()); } }
private void method_0() { while (!this.bool_2) { if (this.bool_3) { break; } if ((this.udpClient_0 != null) && ((this.udpClient_0.Available > 5) || this.udpClient_0.Client.Connected)) { byte[] buffer; try { buffer = this.udpClient_0.Receive(ref this.ipendPoint_0); } catch (Exception exception) { this.ilog_0.ErrorFormat("接收数据异常:{0}", exception.ToString()); Thread.Sleep(500); continue; } object obj2 = SerializeTool.Deserialize(buffer); Type type = obj2.GetType(); if (type == typeof(LoginOKMessage)) { LoginOKMessage message = (LoginOKMessage)obj2; this.bool_1 = true; if (message.Code.Equals("0000")) { this.bool_0 = true; } this.ipendPoint_1 = message.EndPoint; this.method_2(message); } else if (type == typeof(HtmlMessage)) { HtmlMessage message2 = (HtmlMessage)obj2; ReceiveOKMessage message3 = new ReceiveOKMessage(this.string_0, this.string_1, message2.Id); buffer = SerializeTool.Serialize(message3); this.udpClient_0.Send(buffer, buffer.Length, this.ipendPoint_0); this.method_1(message2); } else if (type == typeof(StopSrvMessage)) { this.bool_3 = true; StopSrvMessage message4 = (StopSrvMessage)obj2; this.method_3(message4); } else { this.ilog_0.ErrorFormat("接收到的消息格式错误:{0}", type.ToString()); } } else if (!this.bool_0 && (DateTime.Now.Subtract(this.dateTime_0).TotalSeconds > this.MaxConnWaitTime)) { this.dateTime_0 = DateTime.Now.AddYears(1); LoginOKMessage message5 = new LoginOKMessage("Z999", new IPEndPoint(IPAddress.Any, 0)) { Mess = string.Concat(new object[] { "登录超时[", this.ipendPoint_0.Address, ":", this.ipendPoint_0.Port, "]" }) }; this.method_2(message5); } Thread.Sleep(500); } bool flag = this.bool_3; this.bool_3 = false; this.bool_2 = false; if (flag && (this.ReConnectEvent != null)) { this.ReConnectEvent(); } }