using System.Collections; using System.Net.Sockets; namespace JiLinApp.Docking.VibrateAlarm; public class ClientMessage { public TcpClient client { get; set; } public TcpAlarmHostTable host { get; set; } public string IP { get { if (host != null) return host.ip; if (client != null) return client.Client.RemoteEndPoint.ToString().Split(':')[0]; return ""; } } public string Port { get { if (host != null) return host.port; if (client != null) return client.Client.RemoteEndPoint.ToString().Split(':')[1]; return "-1"; } } public List list { get; set; } public Hashtable sectioTable { get; set; } public ClientMessage() { list = new List(); host = null; sectioTable = new Hashtable(); } public List getMessageList() { List msglist = new List(); while (list.Count >= 19) { if (list[0] == 0xAA && list[1] == 0xAA) { int num = list[17]; if (list.Count < 19 + num) { break; } else { byte[] bytes = new byte[num + 19]; for (int i = 0; i < bytes.Length; i++) { bytes[i] = list[i]; } msglist.Add(bytes); list.RemoveRange(0, num + 19); } } else { list.RemoveAt(0); } } return msglist; } }