Ejemplo n.º 1
0
        private void button1_Click(object sender, EventArgs e)
        {
            client             = new jabber.client.JabberClient();
            client.Password    = txtPassword.Text.Trim();
            client.User        = txtUsername.Text.Trim();
            client.Server      = txtServer.Text.Trim();
            client.OnReadText += (ss, ee) => {
                var ll = "";
            };
            client.OnMessage += (ss, ee) =>
            {
                _sync.Send(x => {
                    var txt = $"Pesan dari <{ee.From}> {ee.Body}\n";
                    rtf.AppendText(txt);
                }, null);
            };


            client.Connect();
            client.Login();
            //client.SetStatus(new Status(Availability.Online, "kiosgamer",priority: 127));
            var txt2 = $"Terkoneksi ke <{client.JID}>\n";

            rtf.AppendText(txt2);

            btnConnect.Enabled    = false;
            btnDisconnect.Enabled = true;
        }
Ejemplo n.º 2
0
        private void jc_OnRegistered(object sender,
                                     IQ iq)
        {
            JabberClient jc = (JabberClient)sender;

            if (iq.Type == IQType.result)
            {
                jc.Login();
            }
        }
Ejemplo n.º 3
0
        static void Main(string[] args)
        {
            if (DEBUG)
            {
                Console.Title = "[DEBUG] " + BOTNAME + " by Entropy";
            }
            else
            {
                Console.Title = BOTNAME + " by Entropy";
            }
            bool   firstrun = true;
            string hostname = "xmpp.livecoding.tv";
            JID    jid      = new JID(username + "@livecoding.tv");

            client              = new JabberClient();
            client.User         = jid.User;
            client.Password     = password;
            client.Server       = jid.Server;
            client.NetworkHost  = hostname;
            client.Resource     = BOTNAME;
            client.AutoPresence = true;
            client.Connect();
            client.Login();
            client.OnConnect      += Client_OnConnect;
            client.OnAuthenticate += Client_OnAuthenticate;
            while (true)
            {
                if (firstrun)
                {
                    Thread.Sleep(5000);
                    firstrun = false;
                }
                else
                {
                    Thread.Sleep(500);
                }
                if (messages.Count > 0)
                {
                    Message latestMsg = messages[messages.Count - 1];
                    if (latestMsg.ID != lastId)
                    {
                        processMessage(latestMsg);
                        if (DEBUG)
                        {
                            Console.WriteLine("{message: \"" + latestMsg.Body + "\", ID: " + latestMsg.ID + "}");
                        }
                    }
                    lastId = latestMsg.ID;
                }
            }
        }
Ejemplo n.º 4
0
    public override bool Connect()
    {
        if (Connected)
        {
            return(true);
        }

        ConnectionThread = new Thread(() =>
        {
            if (Connected)
            {
                try
                {
                    if (Client != null)
                    {
                        Log.AddMessage("Jabber", " [W] Closing unclosed XMPP connection. Should not happen");
                        Client.Logout();
                    }
                }
                catch (Exception ex)
                {
                }
            }

            try
            {
                Log.AddMessage("Jabber", " [i] Connecting...");
                Client = new JabberClient(Server, ServerPort);
                Client.MessageHandler          = new MessageHandlerDelegate(JabberMessageHandler);
                Client.PresenceHandler         = new PresenceHandlerDelegate(JabberPresenceHandler);
                Client.ConnectionStatusHandler = new ConnectionStatusHandlerDelegate(JabberConnectionStatusHandler);

                if (!Client.Login(Jid, Password, Resource))
                {
                    Log.AddMessage("Jabber", " [E] Failed to log in. Wrong username/password?");
                    Disconnect();
                    return;
                }
            }
            catch (Exception ex)
            {
                Log.AddMessage("Jabber", "Exception: " + ex.ToString());
            }
        });

        ConnectionThread.Start();
        return(true);
    }
Ejemplo n.º 5
0
 private void jabber_OnRegistered(object sender, IQ iq)
 {
     _jabberClient.Login();
 }