Пример #1
0
 public Sender(Connector parent, string serverName, string serverType, ErrorCollectorHandler handler)
 {
     this._parent     = parent;
     this._serverName = serverName.ToLower();
     this._serverType = serverType.ToLower();
     this._serverKey  = string.Empty;
     this._lastStats  = new Sender.StatsInfo();
     this._handler    = handler;
     this._stopwatch_Restart.Stop();
     this._stopwatch_Restart.Reset();
     this.SetNotReturnPacketList();
 }
 private Connector(string serverName, string serverType, string connectIP, int connectPort, ErrorCollectorHandler handler, bool useRecvThread, bool useTimeout)
 {
     this._recvRun       = false;
     this._sendRun       = false;
     this._serverName    = serverName;
     this._serverType    = serverType;
     this._connectIP     = IPAddress.Parse(connectIP);
     this._connectPort   = connectPort;
     this._handler       = handler;
     this._sender        = new Sender(this, serverName, serverType, this._handler);
     this._receiver      = new Receiver(this);
     this._useRecvThread = useRecvThread;
     this._useTimeout    = useTimeout;
 }
        public static bool Start(string serverName, string serverType, ErrorCollectorHandler handler, string local_location, string url_location, bool useUpdateThread = true, bool useAutoReconnect = false, bool useTimeout = true)
        {
            string empty = string.Empty;
            string url   = string.Format("{0}{1}info.txt", url_location, serverType.ToLower());

            if (!Connector.m_parallelServer.LoadServerList(url, ref empty))
            {
                handler.Occur_SettingError(empty);
                return(false);
            }
            if (Connector.m_parallelServer.ServerListCount == 0)
            {
                handler.Occur_SettingError(serverName + " info not exist");
                return(false);
            }
            return(Connector.Start(serverName, serverType, Connector.m_parallelServer.GetIP(), Connector.m_parallelServer.GetPORT(), handler, local_location, useUpdateThread, useAutoReconnect, useTimeout));
        }
 public static bool Start(string serverName, string serverType, string connectIP, int connectPort, ErrorCollectorHandler handler, string local_location, bool useUpdateThread = true, bool useAutoReconnect = false, bool useTimeout = true)
 {
     if (Connector._connector == null)
     {
         Connector._connector                = new Connector(serverName, serverType.ToLower(), connectIP, connectPort, handler, useUpdateThread, useTimeout);
         Connector._connector._logPath       = local_location;
         Connector._connector._autoReconnect = useAutoReconnect;
         return(Connector._connector.Open());
     }
     if (Connector._connector._sock == null)
     {
         return(Connector._connector.Open());
     }
     if (!Connector._connector._sock.Connected)
     {
         Connector._connector.Connect();
     }
     return(true);
 }