public void Connect(HTransportOptions options)
        {
            this.connStatus = ConnectionStatus.CONNECTING;
            this.options = options;

            //TODO init the connection timeout value!!
            connTimeout = new TimeSpan(0, 0, 0, 0, options.Timeout);

            string endpointHost = options.EndpointHost;
            int endpointPort = options.EndpointPort;
            string endpointPath = options.EndpointPath;

            string endpointAdress = ToEndpointAdress(endpointHost, endpointPort, endpointPath);

            connTimeoutTimer = ThreadPoolTimer.CreateTimer(timeout_Elapsed, connTimeout);

            socketIO = new Client(endpointAdress);

            socketIO.Message += socketIO_Message;
            socketIO.SocketConnectionClosed += socketIO_SocketConnectionClosed;
            socketIO.Error += socketIO_Error;
            socketIO.On("connect", (message) =>
                {
                    if (this.options.AuthCb != null)
                        this.options.AuthCb(options.Login, Login);
                    else
                        Login(options.Login, options.Password);
                });
            socketIO.ConnectAsync();
        }
 public async void Connect(HTransportOptions tOptions)
 {
     this.tOptions = tOptions;
     this.shouldConnect = true;
     if (connStatus != ConnectionStatus.CONNECTED && connStatus != ConnectionStatus.CONNECTING)
         await ThreadPool.RunAsync(TryToConnectDisconnect, WorkItemPriority.High);
     else if (connStatus == ConnectionStatus.CONNECTING)
         this.onStatus(ConnectionStatus.CONNECTING, ConnectionErrors.CONN_PROGRESS, ErrorMessage.connWhileConnecting);
     else if (connStatus == ConnectionStatus.CONNECTED)
         this.onStatus(ConnectionStatus.CONNECTED, ConnectionErrors.ALREADY_CONNECTED, ErrorMessage.alreadyConn);
 }
Ejemplo n.º 3
0
 public HClient()
 {
     transportOptions = new HTransportOptions();
 }