开发者

'agsXMPP.MessageGrabber' is a 'type' but is used like a 'variable'

here's the code:

  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); };

updated new code:

    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); };

what am i ddoing wrong? why am i getting this error?


you probably need to pass a delegate method, try adding this method to your code

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) {
}

this is the last thing i can suggest but the above method works and will fix your problem, unless you have other problems elsewhere:

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);


new MessageCB(MessageGrabber)

should probably be:

new MessageCB(xmpp.MessageGrabber)

As for what you're doing wrong, you are using the type agsXMPP.MessageGrabber like a variable, which will not compile.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜