質問

使い始めようとしています agsXMPP, しかし、いくつか問題があります。このコードを実行しようとしています:

using System;
using agsXMPP;

namespace TestAgs
{
    class MainClass
    {
        public static void Main (string[] args)
        {
            XmppClientConnection connection = new XmppClientConnection ();
            connection.OnLogin += delegate {
                Console.WriteLine ("logged in");
            };
            connection.Server = "gmail.com";
            connection.ConnectServer = "talk.google.com";
            connection.Username = "my username"; // I tried both with and without '@gmail.com'
            connection.Password = "my password";
            connection.Open();
        }
    }
}

これは正常にコンパイルされますが、実行しようとしても何も起こりません。実行され、エラーは発生せずに完了しますが、「ログイン中」というメッセージがコンソールに出力されません。私の何が間違っているのでしょうか?

違いがあるとすれば、私は Ubuntu 10.04 で Mono 2.4 を使用しています。

役に立ちましたか?

解決

connection.open()ブロックがない限り、この問題はあなたのプログラムがメインの終わりにヒットするので、実行されて終了します。

あなたが出ることからあなたがやろうとしているものに依存したいのですが、1つの方法はManualResetEventになるでしょう:

var mre = new System.Threading.ManualResetEvent (false);
mre.WaitOne ();
. もちろん、あなたは反対の問題を抱えているかもしれません、あなたのアプリが終わる方法はありません。

他のヒント

問題はポート番号であると思います。接続に5222または5223を供給しませんでした。

console.readline()を追加するだけです。line 'connection.open()の後。

// connection.Server = "gmail.com";
connection.ConnectServer = "talk3.l.google.com"; OR
connection.ConnectServer = "talk2.l.google.com";
connection.Username = "my username"; // I tried both with and without '@gmail.com'
connection.Password = "my password";
connection.Open();

talk3.l.google 私にとってはうまくいきました。

ライセンス: CC-BY-SA帰属
所属していません StackOverflow
scroll top