コード例 #1
0
        /// <summary>
        /// Constructor with standard settings for a new HarmonyClient
        /// </summary>
        /// <param name="ipAddress"></param>
        /// <param name="port"></param>
        /// <param name="token"></param>
        public HarmonyClient(string ipAddress, int port, string token)
        {
            Xmpp = new HarmonyClientConnection(ipAddress, port);
            Xmpp.OnLogin += delegate { Wait.Set(); };

            _username = string.Format("{0}@x.com", token);
            _token = token;
        }
コード例 #2
0
        /// <summary>
        /// Constructor with standard settings for a new HarmonyClient
        /// </summary>
        /// <param name="ipAddress"></param>
        /// <param name="port"></param>
        /// <param name="token"></param>
        public HarmonyClient(string ipAddress, int port, string token)
        {
            Xmpp          = new HarmonyClientConnection(ipAddress, port);
            Xmpp.OnLogin += delegate { Wait.Set(); };

            _username = string.Format("{0}@x.com", token);
            _token    = token;
        }
コード例 #3
0
ファイル: HarmonyClient.cs プロジェクト: slavikko/harmony
        /// <summary>
        /// Constructor with standard settings for a new HarmonyClient
        /// </summary>
        /// <param name="ipAddress"></param>
        /// <param name="port"></param>
        /// <param name="token"></param>
        public HarmonyClient(string ipAddress, int port, string token)
        {
            Xmpp = new HarmonyClientConnection(ipAddress, port);
            Xmpp.OnLogin += delegate { Wait = false; };

            SessionToken = token;
            string username = string.Format("{0}@x.com", token);

            Xmpp.OnIq += OnIq;
            Xmpp.Open(username, token);

            WaitForData(5);
        }
コード例 #4
0
        /// <summary>
        /// Constructor with standard settings for a new HarmonyClient
        /// </summary>
        /// <param name="ipAddress"></param>
        /// <param name="port"></param>
        /// <param name="token"></param>
        public HarmonyClient(string ipAddress, int port, string token)
        {
            Xmpp          = new HarmonyClientConnection(ipAddress, port);
            Xmpp.OnLogin += delegate { Wait = false; };

            SessionToken = token;
            string username = $"{token}@x.com";

            Xmpp.OnIq += OnIq;
            Xmpp.Open(username, token);

            WaitForData(5);
        }
コード例 #5
0
        public ActionResult Network(AuthModels.Network model)
        {
            if (ModelState.IsValid)
            {
                bool success = false;
                try
                {
                    var conn = new HarmonyClientConnection(model.Hostname, 5222);
                    var manualEvent = new ManualResetEvent(false);
                    conn.ClientSocket.OnConnect += (obj) =>
                    {
                        success = true;
                        manualEvent.Set();
                    };
                    conn.OnSocketError += (obj, ex) =>
                    {
                        manualEvent.Set();
                    };
                    try
                    {
                        conn.Open();
                        manualEvent.WaitOne(5000);
                    }
                    finally
                    {
                        try { conn.Close(); } catch { }
                    }
                }
                catch { }

                if (!success)
                {
                    ModelState.AddModelError("Hostname", "Your Harmony Hub could not be reached");
                }

                if (ModelState.IsValid)
                {
                    var model2 = new AuthModels.Login
                    {
                        State = model.State,
                        Hostname = Request.UserHostAddress
                    };

                    return View("Login", model2);
                }
            }

            return View(model);
        }