.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://www.codercto.com/soft/d/411.html

Python编程实战

Python编程实战

[美] Mark Summerfield / 爱飞翔 / 机械工业出版社 / 2014-8 / 69.00元

《python编程实战:运用设计模式、并发和程序库创建高质量程序》由python开发者社区知名技术专家mark summerfield亲笔撰写,全球资深python专家doug hellmann作序鼎力推荐,是python领域最有影响力的著作之一。书中通过大量实用的范例代码和三个完整的案例研究,全面而系统地讲解了如何运用设计模式来规划代码结构,如何通过并发与cython等技术提升代码执行速度,以及......一起来看看 《Python编程实战》 这本书的介绍吧!

HTML 压缩/解压工具
HTML 压缩/解压工具

在线压缩/解压 HTML 代码

图片转BASE64编码
图片转BASE64编码

在线图片转Base64编码工具

SHA 加密
SHA 加密

SHA 加密工具