public void OnDataChanged(object sender, DataHandlerEventArgs e) { try { Client c = sender as Client; if (client == null || !client.Equals(c)) client = c; if (e.CMD_ID == HCCommand.EXTEND_COMMAND) { //扩展命令 ProExtend(e); } } catch (System.Exception ex) { } }
void UpdateClient() { foreach (ClientItem clientItem in ServerManager.Instance.ClientManager.ClientList) { if (!clientItem.Client.IsAlive) continue; if (devName == clientItem.Client.Name) { devClient = clientItem.Client; devClient.OnDataChanged += new EventHandler<DataHandlerEventArgs>(devClient_OnDataChanged); break; } } }
void ServerSocketProc() { IPEndPoint ipe = new IPEndPoint(IPAddress.Any, port); serverSocket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp); try { serverSocket.Bind(ipe); serverSocket.Listen(100); Console.WriteLine("Listen {0}", ipe.Port); while (true) { try { Socket clientSocket = serverSocket.Accept(); Client client = new Client(clientSocket); client.Start(); clientMan.Clean(); clientMan.Add(client); //clientListMan.Clean(); //clientListMan.Add(clientPeer); } catch (SocketException ex) { Console.WriteLine(ex.Message); } catch (System.Exception ex) { Console.WriteLine(ex.Message); } } } catch { } }