Exemplo n.º 1
0
        private void BtnUDPServer_Click(object sender, EventArgs e)
        {
            try
            {
                SERVER_CONFIG = DefaultServerConfig;
                ROOT_CONFIG   = new RootConfig();
                udpApp        = new UdpAppServer(app_NewSessionConnected, app_SessionClosed);

                LogHelper.SetOnLog(new LogHelper.LogEvent((m) =>
                {
                    txtAll.Text = string.Join(" ", m, "\r\n");
                    txtAll.Select(txtAll.TextLength, 0);
                    txtAll.ScrollToCaret();
                }));

                udpApp.Setup(ROOT_CONFIG, SERVER_CONFIG);

                if (!udpApp.Start())
                {
                    LogHelper.WriteLog(string.Format("UDP  {0}:{1}启动失败,请检查权限或端口是否被占用!", SERVER_CONFIG.Ip, SERVER_CONFIG.Port), new Exception("启动失败"));
                }
                else
                {
                    LogHelper.WriteLog(string.Format("UDP  {0}:{1}启动 成功!", SERVER_CONFIG.Ip, SERVER_CONFIG.Port));
                    btnUDPServer.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                AppLog.Error("Start App" + ex.ToString());
            }
        }
Exemplo n.º 2
0
        private void BtnUDPServer_Click(object sender, EventArgs e)
        {
            try
            {
                t_btn_kill_Click(null, null);
                //if (PortInUse(int.Parse(VarGlobal.DevicePort)))
                //{
                //    AppLog.Error("Start App Port = " + VarGlobal.DevicePort.ToString() + " Fail");

                //    //LookAndStop(int.Parse(VarGlobal.DevicePort));
                //    t_btn_kill_Click(null,null);
                //    if (PortInUse(int.Parse(VarGlobal.DevicePort)))
                //    {
                //        AppLog.Error("Second Start App Port = " + VarGlobal.DevicePort.ToString() + " Fail");
                //        return;
                //    }

                //}
                //else
                //{

                //}

                SERVER_CONFIG = DefaultServerConfig;
                ROOT_CONFIG   = new RootConfig();
                udpApp        = new UdpAppServer(app_NewSessionConnected, app_SessionClosed);

                LogHelper.SetOnLog(new LogHelper.LogEvent((m) =>
                {
                    txtAll.Text = string.Join(" ", m, "\r\n");
                    txtAll.Select(txtAll.TextLength, 0);
                    txtAll.ScrollToCaret();
                }));

                udpApp.Setup(ROOT_CONFIG, SERVER_CONFIG);

                if (!udpApp.Start())
                {
                    LogHelper.WriteLog(string.Format("UDP  {0}:{1}启动失败,请检查权限或端口是否被占用!", SERVER_CONFIG.Ip, SERVER_CONFIG.Port), new Exception("启动失败"));
                }
                else
                {
                    LogHelper.WriteLog(string.Format("UDP  {0}:{1}启动 成功!", SERVER_CONFIG.Ip, SERVER_CONFIG.Port));
                    btnUDPServer.Enabled = false;
                }
            }
            catch (Exception ex)
            {
                AppLog.Error("Start App" + ex.ToString());
            }
        }
Exemplo n.º 3
0
        private void BtnUDPServer_Click(object sender, EventArgs e)
        {
            initData();
            SERVER_CONFIG = DefaultServerConfig;
            ROOT_CONFIG   = new RootConfig();
            var testServer = new UdpAppServer(app_NewSessionConnected, app_SessionClosed);

            LogHelper.SetOnLog(new LogHelper.LogEvent((m) =>
            {
                txtAll.Text = string.Join(" ", m, "\r\n");
                txtAll.Select(txtAll.TextLength, 0);
                txtAll.ScrollToCaret();
            }));

            testServer.Setup(ROOT_CONFIG, SERVER_CONFIG);
            //testServer.Start();
            if (!testServer.Start())
            {
                LogHelper.WriteLog(string.Format("UDP  {0}:{1}启动失败,请检查权限或端口是否被占用!", SERVER_CONFIG.Ip, SERVER_CONFIG.Port));
            }
        }