コード例 #1
0
ファイル: CommandExecutor.cs プロジェクト: iraychen/IpMsg.Net
		//离开状态或昵称更改
		private void ProcessCommand_BrAbsence(Message message, Host host)
		{
			if (host == null) return;

			host.ChangeAbsenceMode(Consts.Check(message.Options, Consts.Cmd_All_Option.Absence), "");
			if (!string.IsNullOrEmpty(message.NormalMsg)) host.NickName = message.NormalMsg;
			if (!string.IsNullOrEmpty(message.ExtendMessage)) host.GroupName = message.ExtendMessage;
			host.HostFeature = message.Options;
		}
コード例 #2
0
ファイル: CommandExecutor.cs プロジェクト: iraychen/IpMsg.Net
		//AnsEntry
		void ProcessCommand_AnsEntry(Message m, Host h)
		{
			if (h == null && (Config.IgnoreNoAddListFlag || !Consts.Check(m.Options, Consts.Cmd_Send_Option.NoAddList)))
			{
				h = new Host()
				{
					ClientVersion = string.Empty,
					GroupName = m.ExtendMessage,
					HasShare = false,
					HostSub = new HostSub() { HostName = m.HostName, Ipv4Address = m.HostAddr, UserName = m.UserName },
					Index = 0,
					IsEnhancedContractEnabled = Consts.Check(m.Options, Consts.Cmd_All_Option.EnableNewDataContract),
					NickName = m.NormalMsg
				};
				if (Consts.Check(m.Options, Consts.Cmd_All_Option.Absence)) h.ChangeAbsenceMode(true, Resources.CommandExecutor_ProcessCommand_Br_Entry_LeaveModeText);
				LivedHost.Add(m.HostAddr.Address.ToString(), h);
				h.AbsenceModeChanged += Host_AbsendModeChanged;

				//立刻查询离开消息
				if (h.IsInAbsenceMode) Host_AbsendModeChanged(h, null);
				m.Host = h;
			}

			h.SupportEncrypt = Consts.Check(m.Options, Consts.Cmd_All_Option.Encrypt);
			h.SupportFileTransport = Consts.Check(m.Options, Consts.Cmd_All_Option.FileAttach);
		}
コード例 #3
0
ファイル: CommandExecutor.cs プロジェクト: iraychen/IpMsg.Net
		//process received absencemode
		private void ProcessCommand_SendAbsenceInfo(Message message, Host host)
		{
			if (host == null) return;

			host.ChangeAbsenceMode(host.IsInAbsenceMode, message.NormalMsg);
		}
コード例 #4
0
ファイル: CommandExecutor.cs プロジェクト: iraychen/IpMsg.Net
		//Br_Entry
		void ProcessCommand_Br_Entry(Message m, Host h)
		{
			if (h == null && (Config.IgnoreNoAddListFlag || !Consts.Check(m.Options, Consts.Cmd_Send_Option.NoAddList)))
			{
				h = new Host()
				{
					ClientVersion = string.Empty,
					GroupName = m.ExtendMessage,
					HasShare = false,
					HostSub = new HostSub() { HostName = m.HostName, Ipv4Address = m.HostAddr, UserName = m.UserName },
					Index = 0,
					IsEnhancedContractEnabled = Consts.Check(m.Options, Consts.Cmd_All_Option.EnableNewDataContract),
					NickName = m.NormalMsg,
					HostFeature = m.Options
				};
				if (Consts.Check(m.Options, Consts.Cmd_All_Option.Absence)) h.ChangeAbsenceMode(true, Resources.CommandExecutor_ProcessCommand_Br_Entry_LeaveModeText);
				h.SupportEncrypt = Consts.Check(m.Options, Consts.Cmd_All_Option.Encrypt);
				h.SupportFileTransport = Consts.Check(m.Options, Consts.Cmd_All_Option.FileAttach);

				LivedHost.Add(m.HostAddr.Address.ToString(), h);
				h.AbsenceModeChanged += Host_AbsendModeChanged;

				//立刻查询离开消息
				if (h.IsInAbsenceMode) Host_AbsendModeChanged(h, null);
				m.Host = h;
			}

			ulong opt = 0ul;
			if (Config.IsInAbsenceMode) opt |= (ulong)Consts.Cmd_All_Option.Absence;
			if (Config.EnableFileTransfer) opt |= (ulong)Consts.Cmd_All_Option.FileAttach;
			//插件
			if (Config.Services != null) Config.Services.ProviderExecute(s => opt |= s.GenerateClientFeatures());

			//回复证明自己在线
			MessageProxy.SendWithNoCheck(h, Consts.Commands.AnsEntry, opt, Config.NickName, Config.GroupName);

			//如果开启了通知功能,则告知非本网段主机
			if (h != null && Config.EnableHostNotifyBroadcast && !Config.ForceOldContract)
			{
				Host[] list = LivedHost.Values.Where(s => s.HostSub.IPHeader != h.HostSub.IPHeader && h.IsEnhancedContractEnabled).Distinct(Helper.HostSubEqualityCompare.StaticObj).ToArray();
				Array.ForEach(list, s => MessageProxy.SendWithNoCheck(s, Consts.Commands.Br_Entry_Forward, 0, s.HostSub.Ipv4Address.Address.GetAddressBytes(), BitConverter.GetBytes(s.HostSub.PortNo)));
			}
		}