Exemple #1
0
 public GuildChatWebMember(long cid, long guildID, string sender, HeroesGuildChatRelay server)
 {
     this.CID       = cid;
     this.GuildID   = guildID;
     this.Sender    = sender;
     this.ChatRelay = server;
 }
Exemple #2
0
        public void JoinWebChatMember(HeroesGuildChatRelay server, ChatJoinEventArg arg)
        {
            if (!FeatureMatrix.IsEnable("UseHeroesGuildChatServer"))
            {
                arg.Callback(null, arg.AsyncResult);
            }
            Log <GuildService> .Logger.InfoFormat("JoinWebChatMember is called. [ {0}, {1}, {2} ]", arg.GuildKey, arg.CID, arg.Sender);

            IEntity entityByID = base.GetEntityByID(arg.GuildKey);

            if (entityByID != null && entityByID.Tag is GuildEntity)
            {
                Log <GuildService> .Logger.InfoFormat("JoinWebChatMember is called. [ {0}, {1}, {2}, found ]", arg.GuildKey, arg.CID, arg.Sender);

                GuildEntity entity = entityByID.Tag as GuildEntity;
                if (this.DoJoinWebChatMember(entity, server, arg))
                {
                    arg.Callback(this.GetGameMembers(arg.GuildKey), arg.AsyncResult);
                    return;
                }
                Log <GuildService> .Logger.WarnFormat("JoinWebChatMember(). DoJoinWebChatMember is failed [ {0}, {1}, {2} ]", arg.GuildKey, arg.CID, arg.Sender);
            }
            else
            {
                Log <GuildService> .Logger.InfoFormat("JoinWebChatMember(). cannot find guild entity [ {0}, {1}, {2} ]", arg.GuildKey, arg.CID, arg.Sender);
            }
            arg.Callback(null, arg.AsyncResult);
        }
Exemple #3
0
        private void LeaveAllGuildChatWebMember(HeroesGuildChatRelay server)
        {
            Log <GuildService> .Logger.InfoFormat(" LeaveAllGuildChatWebMember is called.", new object[0]);

            foreach (GuildChatWebMember member in server.WebMembers)
            {
                this.LeaveChatRoom(member);
            }
            server.Clear();
        }
Exemple #4
0
        private void LeaveWebChatMember(HeroesGuildChatRelay server, long cid)
        {
            GuildChatWebMember guildChatWebMember = server[cid];

            if (guildChatWebMember != null)
            {
                this.LeaveChatRoom(guildChatWebMember);
                server.LeaveWebMember(cid);
            }
        }
Exemple #5
0
        private void RelayServerDisconnected(HeroesGuildChatRelay server)
        {
            if (!this.chatRelay.GracefullyClosed)
            {
                Scheduler.Cancel(this.chatRelaySchedule);
                this.LeaveAllGuildChatWebMember(this.ChatRelay);
                this.chatRelayInitialized = false;
                Log <GuildService> .Logger.Fatal("Web Chat Relay Server Disconnected.");

                Scheduler.Schedule(base.Thread, Job.Create(new Action(this.ReConnectToRelayServer)), 30000);
                return;
            }
            Log <GuildService> .Logger.Info("Disconnected from Web Chat Relay Server.");
        }
Exemple #6
0
        private void WebChat(HeroesGuildChatRelay server, ChatEventArg arg)
        {
            GuildChatWebMember guildChatWebMember = server[arg.CID];

            if (guildChatWebMember != null)
            {
                IEntity entityByID = base.GetEntityByID(guildChatWebMember.GuildID);
                if (entityByID != null)
                {
                    GuildEntity guildEntity = entityByID.Tag as GuildEntity;
                    if (guildEntity != null && guildEntity.ChatRoom != null)
                    {
                        guildEntity.ChatRoom.OnReceiveChatMessage(guildChatWebMember.CID, guildChatWebMember.Sender, arg.Message, false);
                    }
                }
            }
        }
Exemple #7
0
        public void SyncWebMember(HeroesGuildChatRelay server, ChatMemberSyncEventArg arg)
        {
            Log <GuildService> .Logger.InfoFormat("SyncWebMember is called. [ {0} ]", arg.GuildKey);

            IEntity entityByID = base.GetEntityByID(arg.GuildKey);

            if (entityByID != null && entityByID.Tag is GuildEntity)
            {
                Log <GuildService> .Logger.InfoFormat("SyncWebMember is called. [ {0}, found gid ]", arg.GuildKey);

                GuildEntity guildEntity = entityByID.Tag as GuildEntity;
                if (this.DoSyncWebMember(guildEntity, server, arg))
                {
                    return;
                }
                Log <GuildService> .Logger.ErrorFormat("DoSyncWebMember is failed [{0}, {1}, {2}]", guildEntity.ToString(), server.ToString(), arg.ToString());
            }
        }
Exemple #8
0
        private bool DoJoinWebChatMember(GuildEntity entity, HeroesGuildChatRelay server, ChatJoinEventArg arg)
        {
            if (entity != null && entity.ChatRoom != null)
            {
                Log <GuildService> .Logger.InfoFormat("JoinWebChatMember is called. [ {0}, {1}, {2} ]", arg.GuildKey, arg.CID, arg.Sender);

                GuildChatWebMember member = new GuildChatWebMember(arg.CID, arg.GuildKey, arg.Sender, server);
                if (entity.ChatRoom.JoinWebMember(member))
                {
                    string gameMembers = this.GetGameMembers(arg.GuildKey);
                    Log <GuildService> .Logger.InfoFormat("JoinWebChatMember is called. [ {0}, {1}, {2}, {3} ]", new object[]
                    {
                        arg.GuildKey,
                        arg.CID,
                        arg.Sender,
                        gameMembers
                    });

                    server.JoinWebMember(member);
                    return(true);
                }
            }
            return(false);
        }
Exemple #9
0
        private bool DoSyncWebMember(GuildEntity entity, HeroesGuildChatRelay server, ChatMemberSyncEventArg arg)
        {
            if (entity != null && entity.ChatRoom != null)
            {
                GuildChatRoom chatRoom = entity.ChatRoom;
                chatRoom.LeaveAllMembers(entity.GuildID);
                foreach (KeyValuePair <long, string> keyValuePair in arg.Members)
                {
                    Log <GuildService> .Logger.InfoFormat("DoSyncWebMember is called. [ {0}, {1}, {2} ]", arg.GuildKey, keyValuePair.Key, keyValuePair.Value);

                    GuildChatWebMember guildChatWebMember = new GuildChatWebMember(keyValuePair.Key, arg.GuildKey, keyValuePair.Value, server);
                    if (!chatRoom.JoinWebMember(guildChatWebMember))
                    {
                        this.ChatRelay.KickMember(guildChatWebMember.GuildID, guildChatWebMember.CID);
                    }
                    else
                    {
                        server.JoinWebMember(guildChatWebMember);
                    }
                }
                return(true);
            }
            return(false);
        }
Exemple #10
0
 private void WebClosed(HeroesGuildChatRelay server)
 {
     this.LeaveAllGuildChatWebMember(server);
 }