Esempio n. 1
0
 public HOptions(HOptions options)
 {
     SetEndpoints(options.GetEndpoints());
     SetTransport(options.GetTransport());
     SetTimeout(options.GetTimeout());
     SetMsgTimeout(options.GetMsgTimeout());
 }
Esempio n. 2
0
 public HOptions(HOptions options)
 {
     SetEndpoints(options.GetEndpoints());
     SetTransport(options.GetTransport());
     SetTimeout(options.GetTimeout());
     SetMsgTimeout(options.GetMsgTimeout());
 }
        public MainPage()
        {
            this.InitializeComponent();
            client = new HClient();
            options = new HOptions();

            client.onMessage += client_onMessage;
            client.onStatus += client_onStatus;

        }
Esempio n. 4
0
        private void fillTransportOptions(string login, string password, HOptions options, JObject context)
        {
            try
            {

                this.transportOptions.Login = login;
                this.transportOptions.Password = password;
                this.transportOptions.Timeout = options.GetTimeout();
                this.transportOptions.AuthCb = options.AuthCb;

                //for endpoints, pick one randomly and fill transport options
                if (options.GetEndpoints().Count() > 0)
                {
                    int endpointIndex = HUtil.PickIndex(options.GetEndpoints());
                    string endpoint = options.GetEndpoints()[endpointIndex].ToString();

                    transportOptions.EndpointHost = HUtil.GetHost(endpoint);
                    transportOptions.EndpointPort = HUtil.GetPort(endpoint);
                    transportOptions.EndpointPath = HUtil.GetPath(endpoint);
                }
                else
                {
                    transportOptions.EndpointHost = null;
                    transportOptions.EndpointPort = 0;
                    transportOptions.EndpointPath = null;
                }
            }
            catch (Exception e)
            {
                Debug.WriteLine("{0} : ", e);
            }
        }
Esempio n. 5
0
 /// <summary>
 /// Connect to server
 /// </summary>
 /// <param name="login"></param>
 /// <param name="password"></param>
 /// <param name="options"></param>
 public void Connect(string login, string password, HOptions options)
 {
     this.Connect(login, password, options, null);
 }
Esempio n. 6
0
        /// <summary>
        /// Connect to server
        /// </summary>
        /// <param name="login">user jid i.e.(my_user@domain/resource)</param>
        /// <param name="password"></param>
        /// <param name="options"></param>
        /// <param name="context"></param>
        public void Connect(string login, string password, HOptions options, JObject context)
        {
            bool shouldConnect = false;
            bool connInprogress = false;
            bool disconnInprogress = false;
            this.options = new HOptions(options);

            if (this.connectionStatus == ConnectionStatus.DISCONNECTED)
            {
                shouldConnect = true;
                connectionStatus = ConnectionStatus.CONNECTING;
            }
            if (this.connectionStatus == ConnectionStatus.CONNECTING)
                connInprogress = true;
            if (this.connectionStatus == ConnectionStatus.DISCONNECTING)
                disconnInprogress = true;

            if (shouldConnect)
            {

                fillTransportOptions(login, password, options, context);

                if (options.GetTransport() == "socketio")
                {
                    if (transport == null || !(transport is HTransportSocketIO))
                    {
                        this.transport = new HTransportSocketIO();
                    }
                    if (transportManager == null)
                        this.transportManager = new HTransportManager(this.transport);
                    if (!isEventHandlerAdded)
                    {
                        this.transportManager.onStatus = transport_onStatus;
                        this.transportManager.onData = transport_onData;
                        isEventHandlerAdded = true;
                    }
                    notifyStatus(ConnectionStatus.CONNECTING, ConnectionErrors.NO_ERROR, null);
                    this.transportManager.Connect(this.transportOptions);
                }
            }
            else
            {
                if (connInprogress)
                    notifyStatus(ConnectionStatus.CONNECTING, ConnectionErrors.CONN_PROGRESS, null);
                else if (disconnInprogress)
                    notifyStatus(ConnectionStatus.DISCONNECTING, ConnectionErrors.ALREADY_CONNECTED, null);
                else
                    notifyStatus(ConnectionStatus.CONNECTED, ConnectionErrors.ALREADY_CONNECTED, null);
            }
        }