| 注册
请输入搜索内容

热门搜索

Java Linux MySQL PHP JavaScript Hibernate jQuery Nginx
webphp
13年前发布

.NET的XMPP开发包 JabberNet

     JabberNet 是一个 .NET 的 Jabber (XMPP)协议的客户端开发包,示例代码:    <pre class="brush:c#; toolbar: true; auto-links: false;">using System; using System.Threading;  using jabber.client;  namespace SendMessage {     class Program     {         // we will wait on this event until we're done sending         static ManualResetEvent done = new ManualResetEvent(false);         // if true, output protocol trace to stdout         const bool VERBOSE = true;         const string TARGET = "otheruser@example.com";          static void Main(string[] args)         {             JabberClient j = new JabberClient();             // what user/pass to log in as             j.User = "someuser";             j.Server = "example.com";  // use gmail.com for GoogleTalk             j.Password = "somepassword";              // don't do extra stuff, please.             j.AutoPresence = false;             j.AutoRoster = false;             j.AutoReconnect = -1;              // listen for errors.  Always do this!             j.OnError += new bedrock.ExceptionHandler(j_OnError);              // what to do when login completes             j.OnAuthenticate += new bedrock.ObjectHandler(j_OnAuthenticate);              // listen for XMPP wire protocol             if (VERBOSE)             {                 j.OnReadText += new bedrock.TextHandler(j_OnReadText);                 j.OnWriteText += new bedrock.TextHandler(j_OnWriteText);             }                          // Set everything in motion             j.Connect();              // wait until sending a message is complete             done.WaitOne();              // logout cleanly             j.Close();         }          static void j_OnWriteText(object sender, string txt)         {             if (txt == " ") return;  // ignore keep-alive spaces             Console.WriteLine("SEND: " + txt);         }          static void j_OnReadText(object sender, string txt)         {             if (txt == " ") return;  // ignore keep-alive spaces             Console.WriteLine("RECV: " + txt);         }          static void j_OnAuthenticate(object sender)         {             // Sender is always the JabberClient.             JabberClient j = (JabberClient)sender;             j.Message(TARGET, "test");              // Finished sending.  Shut down.             done.Set();         }          static void j_OnError(object sender, Exception ex)         {             // There was an error!             Console.WriteLine("Error: " + ex.ToString());              // Shut down.             done.Set();         }     } }</pre>    <p><strong>项目主页:</strong><a href="http://www.open-open.com/lib/view/home/1326030758500" target="_blank">http://www.open-open.com/lib/view/home/1326030758500</a></p>     
 本文由用户 webphp 自行上传分享,仅供网友学习交流。所有权归原作者,若您的权利被侵害,请联系管理员。
 转载本站原创文章,请注明出处,并保留原始链接、图片水印。
 本站是一个以用户分享为主的开源技术平台,欢迎各类分享!
 本文地址:https://www.open-open.com/lib/view/open1326030758500.html
XMPP 网络工具包