gpt4 book ai didi

c# - 'agsXMPP.MessageGrabber' 是一个 'type' 但像 'variable' 一样使用

转载 作者:行者123 更新时间:2023-11-30 22:45:24 25 4
gpt4 key购买 nike

代码如下:

  XmppClientConnection xmpp = new XmppClientConnection();
xmpp.Server = "gmail.com";
xmpp.ConnectServer = "talk.google.com";
xmpp.Username = "aleksandr.gordon";
xmpp.Password = "password";
xmpp.Open();

agsXMPP.Jid JID = new Jid("thegabmeister1@gmail.com");
xmpp.MessageGrabber.Add(JID, new agsXMPP.Collections.BareJidComparer(), new MessageCB(xmpp.MessageGrabber), null);

agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();
msg.Type = agsXMPP.protocol.client.MessageType.chat;
msg.To = JID;
msg.Body = "how u doing" + DateTime.Now.ToString();

xmpp.OnLogin += delegate(object o) { xmpp.Send(msg); };

更新的新代码:

    agsXMPP.Jid JID = new Jid("thegabmeister@gmail.com");
xmpp.MessageGrabber.Add(JID, new agsXMPP.Collections.BareJidComparer(),
new MessageCB(delegate(object sender, agsXMPP.protocol.client.Message msg, object data)
{
}), null);
agsXMPP.protocol.client.Message msg1 = new agsXMPP.protocol.client.Message();
msg1.Type = agsXMPP.protocol.client.MessageType.chat;
msg1.To = JID;
msg1.Body = "how u doing" + DateTime.Now.ToString();

xmpp.OnLogin += delegate(object o) { xmpp.Send(msg1); };

我做错了什么?为什么会出现此错误?

最佳答案

您可能需要传递一个委托(delegate)方法,尝试将此方法添加到您的代码中

void Login() {
XmppClientConnection xmpp = new XmppClientConnection();
xmpp.Server = "gmail.com";
xmpp.ConnectServer = "talk.google.com";
xmpp.Username = "aleksandr.gordon";
xmpp.Password = "password";
xmpp.Open();

agsXMPP.Jid JID = new Jid("thegabmeister1@gmail.com");
xmpp.MessageGrabber.Add(JID, new agsXMPP.Collections.BareJidComparer(), new MessageCB(GrabMessage), null);

agsXMPP.protocol.client.Message msg = new agsXMPP.protocol.client.Message();
msg.Type = agsXMPP.protocol.client.MessageType.chat;
msg.To = JID;
msg.Body = "how u doing" + DateTime.Now.ToString();

xmpp.OnLogin += delegate(object o) { xmpp.Send(msg); };
}

protected void GrabMessage(object sender, agsXMPP.protocol.client.Message msg, object data) {
}

这是我能建议的最后一件事,但上述方法有效并将解决您的问题,除非您在其他地方有其他问题:

xmpp.MessageGrabber.Add(JID, new agsXMPP.Collections.BareJidComparer(),
new MessageCB(delegate(object sender, agsXMPP.protocol.client.Message msg, object data) {
if (msg.Body != null) {
MessageBox.Show(msg.Body);
}
}), null);

关于c# - 'agsXMPP.MessageGrabber' 是一个 'type' 但像 'variable' 一样使用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/3073022/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com