public void LogNetExample( )
        {
            #region LogNetExample1

            // 设备连接对象的日志
            MelsecMcNet melsec = new MelsecMcNet("192.168.0.100", 6000);

            // 举例实现日志文件为单日志文件
            melsec.LogNet = new HslCommunication.LogNet.LogNetSingle("D://123.txt");

            #endregion

            #region LogNetExample2

            // 一般服务器对象的
            NetSimplifyServer simplifyServer = new NetSimplifyServer( );
            simplifyServer.LogNet              = new HslCommunication.LogNet.LogNetSingle("D://log.txt");
            simplifyServer.ReceiveStringEvent += (HslCommunication.Core.Net.AppSession session, HslCommunication.NetHandle handle, string data) =>
            {
                simplifyServer.SendMessage(session, handle, "Back:" + data);
            };
            simplifyServer.ServerStart(45678);

            #endregion
        }
Exemplo n.º 2
0
        private NetSimplifyServer netSimplify;                                     // 同步网络访问的服务支持

        private void NetSimplifyInitialization( )
        {
            netSimplify = new NetSimplifyServer( );                                // 实例化
            netSimplify.ReceiveStringEvent += NetSimplify_ReceiveStringEvent;      // 服务器接收字符串信息的时候,触发
            netSimplify.LogNet              = LogNet;                              // 设置日志
            netSimplify.ServerStart(23457);                                        // 启动服务
        }
Exemplo n.º 3
0
        private void Start()
        {
            try
            {
                simplifyServer       = new NetSimplifyServer( );                                    // 实例化
                simplifyServer.Token = new Guid(textBox3.Text);                                     // 设置令牌
                simplifyServer.ReceiveStringEvent      += SimplifyServer_ReceiveStringEvent;        // 接收字符串的时候触发
                simplifyServer.ReceiveStringArrayEvent += SimplifyServer_ReceiveStringArrayEvent;
                simplifyServer.LogNet = new HslCommunication.LogNet.LogNetSingle(Application.StartupPath + @"\Logs\log.txt");
                simplifyServer.LogNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;                  // 日志保存前先显示出来

                simplifyServer.AddAccount("admin", "123456");
                simplifyServer.AddAccount("hsl", "test");
                simplifyServer.IsUseAccountCertificate = checkBox1.Checked;
                simplifyServer.ServerStart(int.Parse(textBox1.Text));                               // 启动服务
                userButton1.Enabled = false;


                timerSecond          = new Timer( );                   // 这个定时器的功能是每秒更新在线的客户端数量
                timerSecond.Interval = 1000;
                timerSecond.Tick    += TimerSecond_Tick;
                timerSecond.Start( );
            }
            catch (Exception ex)
            {
                MessageBox.Show("创建失败:" + ex.Message);
            }
        }
        public void TokenServerExample( )
        {
            simplifyServer       = new NetSimplifyServer( );
            simplifyServer.Token = new Guid("787f9607-dd7a-4ba7-9f98-769d24de05df");

            simplifyServer.ReceiveStringEvent += SimplifyServer_ReceiveStringEvent;
            simplifyServer.ServerStart(12345);
        }
Exemplo n.º 5
0
        /// <summary>
        ///     启动服务器的后台存储
        /// </summary>
        /// <param name="port"></param>
        public void ServerStart(int port)
        {
            simplifyServer                     = new NetSimplifyServer();
            simplifyServer.Token               = Token;
            simplifyServer.LogNet              = LogNet;
            simplifyServer.ReceiveStringEvent += SimplifyServer_ReceiveStringEvent;
            simplifyServer.ServerStart(port);

            for (var i = 0; i < deviceCores.Count; i++)
            {
                deviceCores[i].StartRead();
            }
        }
Exemplo n.º 6
0
 private void Start()
 {
     try
     {
         simplifyServer       = new NetSimplifyServer( );
         simplifyServer.Token = new Guid(textBox3.Text);
         simplifyServer.ReceiveStringEvent      += SimplifyServer_ReceiveStringEvent;
         simplifyServer.LogNet                   = new HslCommunication.LogNet.LogNetSingle(Application.StartupPath + @"\Logs\log.txt");
         simplifyServer.LogNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
         simplifyServer.ServerStart(int.Parse(textBox1.Text));
     }
     catch (Exception ex)
     {
         MessageBox.Show("创建失败:" + ex.Message);
     }
 }
Exemplo n.º 7
0
 // 同步传送数据的初始化
 private void Net_Simplify_Server_Initialization()
 {
     try
     {
         net_simplify_server.KeyToken = new Guid("3ee0dbce-3489-4634-9706-fedf7bb61741");   //设置身份令牌,本质就是一个GUID码,验证客户端使用
         string LogSavePath = null;
         net_simplify_server.LogNet = new LogNetSingle(LogSavePath + @"\simplify_log.txt"); //日志路径,单文件存储模式,采用组件信息
         net_simplify_server.LogNet.SetMessageDegree(HslMessageDegree.DEBUG);               //默认debug及以上级别日志均进行存储,根据需要自行选择,DEBUG存储的信息比较多
         net_simplify_server.ReceiveStringEvent += Net_simplify_server_ReceiveStringEvent;  //接收到字符串触发
         net_simplify_server.ReceivedBytesEvent += Net_simplify_server_ReceivedBytesEvent;  //接收到字节触发
         net_simplify_server.ServerStart(15500);                                            //网络端口,此处使用了一个随便填写的端口
     }
     catch (Exception ex)
     {
         SoftBasic.ShowExceptionMessage(ex);
     }
 }
Exemplo n.º 8
0
 private NetSimplifyServer net_simplify_server = new NetSimplifyServer(); //实例化
                                                                          // 同步传送数据的初始化
 public void Net_Simplify_Server_Initialization()
 {
     try
     {
         net_simplify_server.Token  = Guid.Empty;                                          //设置身份令牌,本质就是一个GUID码,验证客户端使用
         net_simplify_server.LogNet = new LogNetSingle(@"E\simplify_log.txt");             //日志路径,单文件存储模式,采用组件信息
         net_simplify_server.LogNet.SetMessageDegree(HslMessageDegree.DEBUG);              //默认debug及以上级别日志均进行存储,根据需要自行选择,DEBUG存储的信息比较多
         net_simplify_server.ReceiveStringEvent += Net_simplify_server_ReceiveStringEvent; //接收到字符串触发
         net_simplify_server.ReceivedBytesEvent += Net_simplify_server_ReceivedBytesEvent; //接收到字节触发
         net_simplify_server.ServerStart(port);                                            //网络端口,此处使用了一个随便填写的端口
         Console.ReadLine();
     }
     catch (Exception ex)
     {
         var val = SoftBasic.GetExceptionMessage(ex);
         Console.WriteLine(val);
     }
 }
Exemplo n.º 9
0
        private void Start()
        {
            try
            {
                simplifyServer       = new NetSimplifyServer( );
                simplifyServer.Token = new Guid(textBox3.Text);
                simplifyServer.ReceiveStringEvent      += SimplifyServer_ReceiveStringEvent;
                simplifyServer.LogNet                   = new HslCommunication.LogNet.LogNetSingle(Application.StartupPath + @"\Logs\log.txt");
                simplifyServer.LogNet.BeforeSaveToFile += LogNet_BeforeSaveToFile;
                simplifyServer.ServerStart(int.Parse(textBox1.Text));
                userButton1.Enabled = false;

                timerSecond          = new Timer( );
                timerSecond.Interval = 1000;
                timerSecond.Tick    += TimerSecond_Tick;
                timerSecond.Start( );
            }
            catch (Exception ex)
            {
                MessageBox.Show("创建失败:" + ex.Message);
            }
        }