如何在Jabber-net库中实现SOCKS5文件传输(XEP-0065) [英] How to implement SOCKS5 File Transfer (XEP-0065) in Jabber-net library
本文介绍了如何在Jabber-net库中实现SOCKS5文件传输(XEP-0065)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
朋友们,
我正在使用.Net Winforms创建一个xmpp客户端。我想让我的应用程序立即传输文件。
我怎样才能使用jabber-net库?
http://xmpp.org/extensions/xep- 0065.html [ ^ ]
我试图扩展一个类来启动SOCKS5 Negotion。但我不知道如何在其中添加Sid和streamhost ...
Hi friends,
I am making an xmpp client using .Net Winforms. I want to enable my app to transfer files now.
How can I do it using jabber-net library ?
http://xmpp.org/extensions/xep-0065.html[^]
I have tried to extend a class to initiate SOCKS5 Negotion. But I don't know How can I add Sid and streamhost in it...
using System;
using System.Diagnostics;
using System.Security.Cryptography;
using System.Xml;
using bedrock.util;
namespace jabber.protocol.iq
{
public partial class URI
{
public const string BSTREAM = "http://jabber.org/protocol/bytestreams";
}
public class ByteStreamFactory : IPacketTypes
{
private static QnameType[] s_qnt = new QnameType[]
{
new QnameType("item", URI.BSTREAM, typeof(jabber.protocol.iq.ByteStream))
};
QnameType[] IPacketTypes.Types { get { return s_qnt; } }
}
/// <summary>
/// A Ping IQ.
/// </summary>
public class ByteStreamIQ : jabber.protocol.client.TypedIQ<ByteStream>
{
/// <summary>
/// Create a Ping IQ.
/// </summary>
/// <param name="doc"></param>
public ByteStreamIQ(XmlDocument doc)
: base(doc)
{
}
}
/// <summary>
/// Ping IQ query.
/// </summary>
public class ByteStream : Element
{
/// <summary>
///
/// </summary>
/// <param name="doc"></param>
public ByteStream(XmlDocument doc) :
base("query", URI.BSTREAM, doc)
{
}
/// <summary>
///
/// </summary>
/// <param name="prefix"></param>
/// <param name="qname"></param>
/// <param name="doc"></param>
public ByteStream(string prefix, XmlQualifiedName qname, XmlDocument doc) :
base(prefix, qname, doc)
{
}
/// <summary>
/// The full JabberID of the entity described.
/// </summary>
public JID JID
{
get { return GetAttribute("jid"); }
set { SetAttribute("jid", value.ToString()); }
}
/// <summary>
/// One of the categories from the category list, or a non-standard category prefixed with the string "x-".
/// </summary>
public string From
{
get { return GetAttribute("from"); }
set { SetAttribute("from", value); }
}
/// <summary>
/// One of the official types from the specified category, or a non-standard type prefixed with the string "x-".
/// </summary>
public string Type
{
get { return GetAttribute("type"); }
set { SetAttribute("type", value); }
}
/// <summary>
/// A friendly name that may be used in a user interface.
/// </summary>
public string BrowseName
{
get { return GetAttribute("name"); }
set { SetAttribute("name", value); }
}
/// <summary>
/// A string containing the version of the node, equivalent to the response provided to a
/// query in the 'jabber:iq:version' namespace. This is useful for servers, especially for lists of services
/// (see the 'service/serverlist' category/type above).
/// </summary>
public string Version
{
get { return GetAttribute("version"); }
set { SetAttribute("version", value); }
}
/// <summary>
/// Sub-items of this item
/// </summary>
/// <returns></returns>
public Browse[] GetItems()
{
return GetElements<Browse>().ToArray();
}
/// <summary>
/// Add an item to the sub-item list.
/// </summary>
/// <returns></returns>
public Browse AddItem()
{
return CreateChildElement<Browse>();
}
/// <summary>
/// The namespaces advertised by this item.
/// </summary>
/// <returns></returns>
public string[] GetNamespaces()
{
XmlNodeList nl = GetElementsByTagName("ns", URI.BSTREAM);
string[] items = new string[nl.Count];
int i=0;
foreach (XmlNode n in nl)
{
items[i] = n.InnerText;
i++;
}
return items;
}
/// <summary>
/// Add a namespace to the namespaces supported by this item.
/// </summary>
/// <param name="ns"></param>
public void AddNamespace(string ns)
{
XmlElement e = this.OwnerDocument.CreateElement(null, "ns", URI.BSTREAM);
e.InnerText = ns;
this.AppendChild(e);
}
}
}
推荐答案
这篇关于如何在Jabber-net库中实现SOCKS5文件传输(XEP-0065)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文