Esempio n. 1
0
 private void NetComplexInitialization( )
 {
     netComplex = new NetComplexServer( );                        // 实例化
     netComplex.AcceptString  += NetComplex_AcceptString;         // 绑定字符串接收事件
     netComplex.ClientOnline  += NetComplex_ClientOnline;         // 客户端上线的时候触发
     netComplex.ClientOffline += NetComplex_ClientOffline;        // 客户端下线的时候触发
     netComplex.LogNet         = LogNet;                          // 设置日志
     netComplex.ServerStart(23456);                               // 启动网络服务
 }
Esempio n. 2
0
 private void ComplexServerInitialization()
 {
     complexServer                         = new NetComplexServer();                              // 实例化
     complexServer.KeyToken                = new Guid("91625bad-d581-44ab-b121-ffff5bcb83fb");    // 设置令牌,提升安全性
     complexServer.LogNet                  = new HslCommunication.LogNet.LogNetSingle("log.txt"); // 设置日志记录,如果不需要,可以删除
     complexServer.ClientOnline           += ComplexServer_ClientOnline;                          // 客户端上线时触发
     complexServer.ClientOffline          += ComplexServer_ClientOffline;                         // 客户端下线时触发
     complexServer.AllClientsStatusChange += ComplexServer_AllClientsStatusChange;                // 只要有客户端上线或下线就触发
     complexServer.AcceptString           += ComplexServer_AcceptString;                          // 客户端发来消息时触发
     complexServer.ServerStart(12345);                                                            // 启动服务,需要选择一个端口
 }
Esempio n. 3
0
 private void ComplexServerStart(int port)
 {
     complexServer                         = new NetComplexServer( );
     complexServer.LogNet                  = logNet;
     complexServer.Token                   = new Guid(textBox3.Text);
     complexServer.AcceptString           += ComplexServer_AcceptString;
     complexServer.AcceptByte             += ComplexServer_AcceptByte;
     complexServer.ClientOnline           += ComplexServer_ClientOnline;
     complexServer.ClientOffline          += ComplexServer_ClientOffline;
     complexServer.AllClientsStatusChange += ComplexServer_AllClientsStatusChange;
     complexServer.ServerStart(port);
 }
Esempio n. 4
0
 private void ComplexServerStart(int port)
 {
     complexServer        = new NetComplexServer( );
     complexServer.LogNet = new HslCommunication.LogNet.LogNetDateTime(Application.StartupPath + "\\Logs", HslCommunication.LogNet.GenerateMode.ByEveryDay);
     complexServer.LogNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
     complexServer.Token          = new Guid(textBox3.Text);
     complexServer.AcceptString  += ComplexServer_AcceptString;
     complexServer.AcceptByte    += ComplexServer_AcceptByte;
     complexServer.ClientOnline  += ComplexServer_ClientOnline;
     complexServer.ClientOffline += ComplexServer_ClientOffline;
     complexServer.ServerStart(port);
 }
Esempio n. 5
0
 private void NetComplexInitialization()
 {
     netComplex = new NetComplexServer();
     netComplex.AcceptString += NetComplex_AcceptString;
     netComplex.ServerStart(23456);
 }