当我尝试连接到服务器时,我有一个问题。我使用的是库agsXMPP和下面的代码。当我尝试连接到服务器时,我无法连接到服务器。我无法在服务器上做日志。我也试着给一些用户发了条消息。
agsXMPP.XmppClientConnection xmpp = new XmppClientConnection();
string server = "ipServer";
string user = "user";
string pass = "password";
int port = 5222;
bool _wait = true;
xmpp.Status = "available";
xmpp.Show = ShowType.chat;
xmpp.Priority = 1;
xmpp.SendMyPresence();
xmpp.Server = server;
xmpp.Port = port;
xmpp.Username = usuCon;
xmpp.Password = usuCon;
xmpp.Open();
agsXMPP.Jid JID = new Jid("example@org.es);
agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();
msg.Type = agsXMPP.protocol.client.MessageType.chat;
msg.To = JID;
msg.Body = "hi how are you? message" + DateTime.Now.ToString();
xmpp.OnLogin += delegate(object o) { xmpp.Send(msg); };
agsXMPP.protocol.server.Presence presencia2 = new agsXMPP.protocol.server.Presence();
presencia2.Type = new PresenceType();
xmpp.OnLogin += xmpp_OnLogin;
Console.WriteLine("Wait");
int i = 0;
do
{
Console.Write(".");
i++;
if (i == 10)
_wait = false;
Thread.Sleep(1000);
} while (_wait);
Console.WriteLine("\n" + msg);
Console.Read();
}
private void xmpp_OnLogin(object sender)
{
Console.WriteLine("yes");
}发布于 2016-05-04 18:17:34
我有这个问题,我用下面的代码解决了这个问题:
XmppClientConnection xmpp = new XmppClientConnection();
xmpp.ConnectServer = "ipServer";
xmpp.Server = "domain name";
xmpp.Port = 5222;
xmpp.Username = "my userName";
xmpp.Password = "my password";
xmpp.Open();
xmpp.OnLogin += new ObjectHandler(xmpp_OnLogin);https://stackoverflow.com/questions/27953563
复制相似问题