.NET的XMPP开发包 JabberNet

码农软件 · 软件分类 · 网络工具包 · 2019-03-01 18:43:56

软件介绍

JabberNet 是一个 .NET 的 Jabber (XMPP)协议的客户端开发包,示例代码:

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

本文地址:https://codercto.com/soft/d/411.html

精益创业实战

精益创业实战

Ash Maurya / 张玳 / 图灵文化发展有限公司 / 2013-1 / 39.00元

《精益创业实战(第2版)》融合了精益创业法、客户开发、商业模式画布和敏捷/持续集成的精华,讲解精益创业实战法。作者以自己的创业项目为主线,结合大量真实案例,并融入一些伟大创业者的智慧,创建了一套思考、验证和发布产品的系统。那些想要验证自己的创意、解决实际问题和渴望拥有成功事业的人,可以把《精益创业实战(第2版)》当成一套明确的实践计划、一幅清晰的创业路线图、一本实践指南,或者一套反复实践的方法论。一起来看看 《精益创业实战》 这本书的介绍吧!

在线进制转换器
在线进制转换器

各进制数互转换器

SHA 加密
SHA 加密

SHA 加密工具

正则表达式在线测试
正则表达式在线测试

正则表达式在线测试