Ejemplo n.º 1
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);
            }
        }
Ejemplo n.º 2
0
        private void connBt_Click(object sender, RoutedEventArgs e)
        {
            string endpoint = serverTbx.Text;

            if (options.GetEndpoints() != null)
            {
                options.GetEndpoints().Clear();
            }
            if (!string.IsNullOrEmpty(endpoint))
            {
                JArray ja = new JArray();
                ja.Add(endpoint);
                options.SetEndpoints(ja);
            }
            //options.AuthCb = new AuthenticationCallback(
            //   (username, Login) =>
            //   {
            //       Debug.WriteLine("AuthenticationCallback called!");
            //       Login(username, "u1");
            //   }
            //   );

            client.Connect(usernamTbx.Text, passwordTbx.Text, options);
        }