//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); }
//Br_Exit void ProcessCommand_Br_Exit(Message m, Host h) { //如果开启了通知功能,则告知非本网段主机 if (h == null) { return; } LivedHost.Delete(h.HostSub.Ipv4Address.Address.ToString()); //通知非本网段主机 if (Config.EnableHostNotifyBroadcast && !Config.ForceOldContract) { Host[] list = LivedHost.Values.Where(s => s.HostSub.IPHeader != h.HostSub.IPHeader).Distinct(Helper.HostSubEqualityCompare.StaticObj).ToArray(); Array.ForEach(list, s => { MessageProxy.SendWithNoCheck(s, Consts.Commands.Br_Exit_Forward, 0, s.HostSub.Ipv4Address.Address.GetAddressBytes(), BitConverter.GetBytes(s.HostSub.PortNo)); }); } }
//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))); } }