agsXMPP.XmppClientConnection.SendMyPresence C# (CSharp) Method

SendMyPresence() public method

Sends our Presence, the packet is built of Status, Show and Priority
public SendMyPresence ( ) : void
return void
		public void SendMyPresence()
		{
            Presence pres = new Presence(m_Show, m_Status, m_Priority);

            // Add client caps when enabled
            if (m_EnableCapabilities)
            {
                if (m_Capabilities.Version == null)
                    UpdateCapsVersion();

                pres.AddChild(m_Capabilities);
            }

            this.Send(pres);
		}

Usage Example

Ejemplo n.º 1
0
        static void Main(string[] args) {
            Console.Title = "XMPPduino";

            xmppCon = new XmppClientConnection();

            System.ComponentModel.IContainer components = new System.ComponentModel.Container();
            serialPort = new System.IO.Ports.SerialPort(components);

            serialPort.PortName = Config.COM_PORT;
            serialPort.BaudRate = Config.Baud_Rate;

            xmppCon = new XmppClientConnection();
            xmppCon.Username = Config.Username;
            xmppCon.Password = Config.Password;
            xmppCon.SocketConnectionType = agsXMPP.net.SocketConnectionType.Direct;
            xmppCon.ConnectServer = "talk.google.com";
            xmppCon.Port = 5222;
            xmppCon.UseStartTLS = true;
            xmppCon.AutoResolveConnectServer = false;
            xmppCon.Show = ShowType.chat;
            xmppCon.Server = Config.Server;

            xmppCon.AutoAgents = false;
            xmppCon.AutoPresence = true;
            xmppCon.AutoRoster = true;

            try {
                xmppCon.OnRosterStart += new ObjectHandler(xmppCon_OnRosterStart);
                xmppCon.OnRosterItem += new XmppClientConnection.RosterHandler(xmppCon_OnRosterItem);
                xmppCon.OnRosterEnd += new ObjectHandler(xmppCon_OnRosterEnd);
                xmppCon.OnPresence += new PresenceHandler(xmppCon_OnPresence);
                xmppCon.OnMessage += new MessageHandler(xmppCon_OnMessage);
                xmppCon.OnLogin += new ObjectHandler(xmppCon_OnLogin);
                xmppCon.Open();
            }
            catch (Exception e) {
                Console.WriteLine(e.Message);
            }

            Wait("Login to server, please wait");
            bool bQuit = false;

            while (!bQuit) {
                string command = Console.ReadLine();
                string[] commands = command.Split(' ');

                switch (commands[0].ToLower()) {
                    case "quit":
                        bQuit = true;
                        break;
                    case "msg":
                        string msg = command.Substring(command.IndexOf(commands[2]));
                        xmppCon.Send(new Message(new Jid(commands[1]), MessageType.chat, msg));
                        break;
                    case "status":
                        switch (commands[1]) {
                            case "online":
                                xmppCon.Show = ShowType.NONE;
                                break;
                            case "away":
                                xmppCon.Show = ShowType.away;
                                break;
                            case "xa":
                                xmppCon.Show = ShowType.xa;
                                break;
                            case "chat":
                                xmppCon.Show = ShowType.chat;
                                break;
                        }
                        string status = command.Substring(command.IndexOf(commands[2]));
                        xmppCon.Status = status;
                        xmppCon.SendMyPresence();
                        break;
                }
            }
            xmppCon.Close();
        }
All Usage Examples Of agsXMPP.XmppClientConnection::SendMyPresence