⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 jid.cs

📁 语音视频功能 里面实现了基本的QQ与语音对话
💻 CS
字号:
using System;

namespace gowk.core
{
	public class Jid 	{		private string user     = null;		private string server   = null;		private string resource = null;		public Jid()
		{		}		public Jid(string jid)		{			Parse(jid);		}		public Jid(string user,string server)
		{			this.SetUser(user);			this.SetServer(server);		}		public Jid(string user,string server,string res):this(user,server)
		{			this.SetResource(res);		}		public string User
		{			get{return this.user;}			set{this.user=value;}		}		public string Server
		{			get{return this.server;}			set{this.server=value;}		}		public string Resouce
		{			get{return this.resource;}			set{this.resource=value;}		}		private void Parse(string jid)
		{			string server_resource=jid;			if(jid.IndexOf("@")>-1)
			{				string[] ss=jid.Split('@');				this.SetUser(ss[0]);				server_resource=ss[1];			}			int index=server_resource.IndexOf("/");			if(index>-1)
			{				this.SetServer(server_resource.Substring(0,index));				this.SetResource(server_resource.Substring(index+1));			}			else
			{				this.SetServer(server_resource);			}		}		public static bool Equals(string jid1,string jid2,bool compareResource)
		{			Jid a=new Jid(jid1);			Jid b=new Jid(jid2);			bool ret=a.Server==b.Server && a.User==b.User;			if(compareResource)ret&=b.resource==a.resource;			return ret;		}		public static string GetServer(string jid)
		{			return new Jid(jid).Server;		}		public static string GetUsername(string jid)
		{			return new Jid(jid).User;		}		public static string GetResource(string jid)
		{			return new Jid(jid).Resouce;		}		private void SetUser(string name)
		{			Check(name);			this.user=name;		}		private void SetServer(string svr)
		{			Check(svr);			this.server=svr;		}		private void SetResource(string res)
		{			Check(res);			this.resource=res;		}		private void Check(string value)
		{		}
		public override string ToString()
		{
			return this.ToString(true);
		}
		public string ToString(bool widthresource)
		{
			string ret=this.server;
			ret=(this.user==null)?ret:(this.user+"@"+ret);
			if(widthresource)
				ret=(this.resource==null)?ret:(ret+"/"+this.resource);
			return ret;
		}
		public static string GetBareJid(string jid)
		{
			return new Jid(jid).ToString(false);
		}
  }
}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -