本文整理汇总了C#中agsXMPP.XmppClientConnection.SendMyPresence方法的典型用法代码示例。如果您正苦于以下问题:C# XmppClientConnection.SendMyPresence方法的具体用法?C# XmppClientConnection.SendMyPresence怎么用?C# XmppClientConnection.SendMyPresence使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类agsXMPP.XmppClientConnection
的用法示例。
在下文中一共展示了XmppClientConnection.SendMyPresence方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Main
static void Main(string[] args)
{
XmppClientConnection xmppCon = new XmppClientConnection();
Console.Title = "Console Client";
// read the jid from the console
PrintHelp("Enter you Jid ([email protected]): ");
Jid jid = new Jid(Console.ReadLine());
PrintHelp(String.Format("Enter password for '{0}': ", jid.ToString()));
xmppCon.Password = Console.ReadLine();
xmppCon.Username = jid.User;
xmppCon.Server = jid.Server;
xmppCon.AutoAgents = false;
xmppCon.AutoPresence = true;
xmppCon.AutoRoster = true;
xmppCon.AutoResolveConnectServer = true;
// Connect to the server now
// !!! this is asynchronous !!!
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");
PrintCommands();
bool bQuit = false;
while (!bQuit)
{
string command = Console.ReadLine();
string[] commands = command.Split(' ');
switch (commands[0].ToLower())
{
case "help":
PrintCommands();
break;
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;
}
}
// close connection
xmppCon.Close();
}
示例2: Main
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();
}