protected override void TakeRemote() { var session = paramGetter.GetSession(); if (session == null) { ErrorCode = 10000; ErrorInfo = "Sessin is null."; return; } switch (_type) { case NoticeMode.AllService: { var sessionlist = GameSession.GetAll(); foreach (var on in sessionlist) { if (on.Connected && !on.IsRemote) { MsgData data = new MsgData(); data.Type = MsgType.Notice; data.UserId = on.UserId; var parameters = new Parameters(); parameters["Type"] = NoticeMode.AllService; parameters["ServerID"] = _serverID; parameters["Content"] = _content; data.Param = parameters; MsgDispatcher.Push(data); } } } break; case NoticeMode.World: { var cache = new MemoryCacheStruct <ChatUser>(); var list = cache.FindAll(t => t.ServerID == _serverID); foreach (var v in list) { var sess = GameSession.Get(v.UserId); if (sess != null && sess.Connected && !sess.IsRemote) { MsgData data = new MsgData(); data.Type = MsgType.Notice; data.UserId = sess.UserId; var parameters = new Parameters(); parameters["Type"] = NoticeMode.World; parameters["ServerID"] = _serverID; parameters["Content"] = _content; data.Param = parameters; MsgDispatcher.Push(data); } } } break; } }
protected override void TakeRemote() { var remoteSession = paramGetter.GetSession(); if (remoteSession == null) { ErrorCode = 10000; ErrorInfo = "RemoteSession is null."; return; } switch (_chatType) { case ChatType.AllService: { var cache = new MemoryCacheStruct <ChatUser>(); var Sender = cache.Find(t => (t.UserId == _sender)); if (Sender != null) { var sessionlist = GameSession.GetAll(); foreach (var on in sessionlist) { if (on.Connected && !on.IsRemote) { MsgData data = new MsgData(); data.Type = MsgType.Chat; data.UserId = on.UserId; var parameters = new Parameters(); parameters["Type"] = ChatType.AllService; parameters["Sender"] = _sender; parameters["SenderName"] = Sender.UserName; parameters["SenderVipLv"] = Sender.VipLv; parameters["SenderProfession"] = Sender.Profession; parameters["SenderAvatarUrl"] = Sender.AvatarUrl; parameters["ServerID"] = _serverID; parameters["SendDate"] = _sendDate; parameters["Content"] = _content; data.Param = parameters; MsgDispatcher.Push(data); } } } } break; case ChatType.World: { var cache = new MemoryCacheStruct <ChatUser>(); var Sender = cache.Find(t => (t.UserId == _sender)); if (Sender != null) { var list = cache.FindAll(t => t.ServerID == Sender.ServerID); foreach (var v in list) { var session = GameSession.Get(v.UserId); if (session != null && session.Connected && !session.IsRemote) { MsgData data = new MsgData(); data.Type = MsgType.Chat; data.UserId = v.UserId; var parameters = new Parameters(); parameters["Type"] = ChatType.World; parameters["Sender"] = _sender; parameters["SenderName"] = Sender.UserName; parameters["SenderVipLv"] = Sender.VipLv; parameters["SenderProfession"] = Sender.Profession; parameters["SenderAvatarUrl"] = Sender.AvatarUrl; parameters["ServerID"] = _serverID; parameters["SendDate"] = _sendDate; parameters["Content"] = _content; data.Param = parameters; MsgDispatcher.Push(data); } } } } break; case ChatType.Whisper: { var cache = new MemoryCacheStruct <ChatUser>(); var Sender = cache.Find(t => (t.UserId == _sender)); var Receiver = cache.Find(t => (t.UserId == _reveiver)); if (Sender != null && Receiver != null) { var session = GameSession.Get(_reveiver); if (session != null && session.Connected && !session.IsRemote) { MsgData data = new MsgData(); data.Type = MsgType.Chat; data.UserId = _reveiver; var parameters = new Parameters(); parameters["Type"] = ChatType.Whisper; parameters["Sender"] = _sender; parameters["SenderName"] = Sender.UserName; parameters["SenderVipLv"] = Sender.VipLv; parameters["SenderProfession"] = Sender.Profession; parameters["SenderAvatarUrl"] = Sender.AvatarUrl; parameters["ServerID"] = _serverID; parameters["SendDate"] = _sendDate; parameters["Content"] = _content; data.Param = parameters; MsgDispatcher.Push(data); } } } break; case ChatType.Guild: { var cache = new MemoryCacheStruct <ChatUser>(); var Sender = cache.Find(t => (t.UserId == _sender)); if (Sender != null) { if (Sender.GuildID.IsEmpty()) { return; } var list = cache.FindAll(t => t.GuildID == Sender.GuildID); foreach (var v in list) { var session = GameSession.Get(v.UserId); if (session != null && session.Connected && !session.IsRemote) { MsgData data = new MsgData(); data.Type = MsgType.Chat; data.UserId = v.UserId; var parameters = new Parameters(); parameters["Type"] = ChatType.Guild; parameters["Sender"] = _sender; parameters["SenderName"] = Sender.UserName; parameters["SenderVipLv"] = Sender.VipLv; parameters["SenderProfession"] = Sender.Profession; parameters["SenderAvatarUrl"] = Sender.AvatarUrl; parameters["ServerID"] = _serverID; parameters["SendDate"] = _sendDate; parameters["Content"] = _content; data.Param = parameters; MsgDispatcher.Push(data); } } } } break; case ChatType.System: { var cache = new MemoryCacheStruct <ChatUser>(); var Receiver = cache.Find(t => (t.UserId == _reveiver)); if (Receiver != null) { var session = GameSession.Get(_reveiver); if (session != null && session.Connected && !session.IsRemote) { MsgData data = new MsgData(); data.Type = MsgType.Chat; data.UserId = _reveiver; var parameters = new Parameters(); parameters["Type"] = ChatType.System; parameters["Sender"] = 0; parameters["SenderName"] = "系统"; parameters["SenderVipLv"] = 0; parameters["SenderProfession"] = 0; parameters["SenderAvatarUrl"] = string.Empty; parameters["ServerID"] = _serverID; parameters["SendDate"] = _sendDate; parameters["Content"] = _content; data.Param = parameters; MsgDispatcher.Push(data); } } } break; } }