public ScadaServer(string _name, string _ip, ushort _port, SvcManage svc) { state = ServerState.Stoped; serverName = _name; server.Address = _ip; server.Port = _port; Svc = svc; //绑定事件 //绑定监听地址前触发 server.OnPrepareListen += new ServerPrepareListenEventHandler(server_OnPrepareListen); //客户端连接请求被接受后触发 server.OnAccept += new ServerAcceptEventHandler(server_OnAccept); //发送消息后触发 server.OnSend += new ServerSendEventHandler(server_OnSend); //收到消息后触发 server.OnReceive += new PullServerReceiveEventHandler(server_OnReceive); //连接关闭后触发(服务端的连接通常是多个,只要某一个连接关闭了都会触发) server.OnClose += new ServerCloseEventHandler(server_OnClose); //组件停止后触发 server.OnShutdown += new ServerShutdownEventHandler(server_OnShutdown); }
public MainEntry() { ManageSvc = new SvcManage(); host = new ServiceHost(ManageSvc); MyServer = new ScadaServer(name, ip, port, ManageSvc); }