Example #1
0
 public static void stop_tcp_server(ref AsyncTcpServer server, string name)
 {
     try
     {
         if (server != null)
         {
             server.Dispose();
             server = null;
             EzLogger.GlobalLogger.info("stop " + name + " success.");
         }
     }
     catch (System.Exception ex)
     {
         EzLogger.GlobalLogger.warning(string.Format("stop {0} failed: {1}{3}{2}{3}",
                                                     name, ex.Message, ex.StackTrace, Environment.NewLine));
     }
 }
Example #2
0
        public static bool start_tcp_server(ref AsyncTcpServer server, string name, int port, bool check_client_available, Action <IScsServerClient, Cmd> recv_func)
        {
            try
            {
                if (server == null)
                {
                    server = new AsyncTcpServer(port, check_client_available);
                    server.MessageReceived += recv_func;
                    server.Start();
                    EzLogger.GlobalLogger.info("start " + name + " success.");
                }
                return(true);
            }
            catch (System.Exception ex)
            {
                stop_tcp_server(ref server, name);

                EzLogger.GlobalLogger.warning(string.Format("start {0} failed: {1}{3}{2}{3}",
                                                            name, ex.Message, ex.StackTrace, Environment.NewLine));

                return(false);
            }
        }
Example #3
0
 public static void stop_tcp_server(ref AsyncTcpServer server, string name)
 {
     try
     {
         if (server != null)
         {
             server.Dispose();
             server = null;
             EzLogger.GlobalLogger.info("stop " + name + " success.");
         }
     }
     catch (System.Exception ex)
     {
         EzLogger.GlobalLogger.warning(string.Format("stop {0} failed: {1}{3}{2}{3}",
             name, ex.Message, ex.StackTrace, Environment.NewLine));
     }
 }
Example #4
0
        public static bool start_tcp_server(ref AsyncTcpServer server, string name, int port, bool check_client_available, Action<IScsServerClient, Cmd> recv_func)
        {
            try
            {
                if (server == null)
                {
                    server = new AsyncTcpServer(port, check_client_available);
                    server.MessageReceived += recv_func;
                    server.Start();
                    EzLogger.GlobalLogger.info("start " + name + " success.");
                }
                return true;
            }
            catch (System.Exception ex)
            {
                stop_tcp_server(ref server, name);

                EzLogger.GlobalLogger.warning(string.Format("start {0} failed: {1}{3}{2}{3}",
                    name, ex.Message, ex.StackTrace, Environment.NewLine));

                return false;
            }
        }
Example #5
0
 public static int get_server_client_number(AsyncTcpServer server, string client_name)
 {
     try { return server.GetClientStatusNumber(client_name); }
     catch { return 0; }
 }
Example #6
0
 public static int get_server_client_number(AsyncTcpServer server, string client_name)
 {
     try { return(server.GetClientStatusNumber(client_name)); }
     catch { return(0); }
 }