예제 #1
0
        public bool WhisperToGameClient(string from, long cid, string message)
        {
            IEntity entityByID = base.GetEntityByID(cid);

            if (entityByID == null)
            {
                if (base.LookUp.GetLocationCount(base.Category) > 1)
                {
                    int num = this.FindServiceID(cid, base.Category);
                    if (num > 0 && base.ID != num)
                    {
                        base.RequestOperation(num, new WhisperToGameClient(from, cid, message));
                        return(true);
                    }
                }
                return(false);
            }
            TalkClient talkClient = entityByID.Tag as TalkClient;

            if (talkClient != null && talkClient.FrontendConn != null)
            {
                talkClient.FrontendConn.RequestOperation(SendPacket.Create <WhisperMessage>(new WhisperMessage
                {
                    Sender   = from,
                    Contents = message
                }));
                return(true);
            }
            return(false);
        }
예제 #2
0
        protected override IEntity MakeEntity(long id, string category)
        {
            IEntity entity = base.MakeEntity(id, category);

            entity.Tag    = new TalkClient(this, entity);
            entity.Using += delegate(object sender, EventArgs <IEntityAdapter> e)
            {
                IEntityAdapter value = e.Value;
                if (entity.Tag == null)
                {
                    return;
                }
                if (value.RemoteCategory == "FrontendServiceCore.FrontendService")
                {
                    TalkClient talkClient = entity.Tag as TalkClient;
                    if (talkClient.FrontendConn != null)
                    {
                        talkClient.FrontendConn.Close();
                    }
                    talkClient.FrontendConn         = this.Connect(entity, new Location(value.RemoteID, value.RemoteCategory));
                    talkClient.FrontendConn.Closed += delegate(object _, EventArgs <IEntityProxy> __)
                    {
                        entity.Close();
                    };
                    talkClient.FrontendConn.OperationQueueOversized += delegate(object _, EventArgs <IEntityProxy> __)
                    {
                        entity.Close(true);
                    };
                }
            };
            entity.Closed += delegate(object sender, EventArgs e)
            {
                try
                {
                    EntityDataContext entityDataContext = new EntityDataContext();
                    entityDataContext.AcquireService(new long?((sender as IEntity).ID), base.Category, new int?(-1), new int?(base.ID));
                }
                catch (Exception ex)
                {
                    Log <TalkService> .Logger.ErrorFormat("Entity_Closed [EntityID : {0}] [ServiceID : {1}] [Category : {2}] - {3} ", new object[]
                    {
                        (sender as IEntity).ID,
                        base.ID,
                        base.Category,
                        ex
                    });
                }
            };
            entity.Used += delegate(object sender, EventArgs <IEntityAdapter> e)
            {
                if (entity.UseCount == 0)
                {
                    entity.Close();
                }
            };
            return(entity);
        }
예제 #3
0
 private void SendAsyncResult(TalkService.WhisperAnyncArguments args)
 {
     if (args != null)
     {
         IEntity entityByID = base.GetEntityByID(args.FromCid);
         if (entityByID != null && entityByID.Tag != null)
         {
             TalkClient talkClient = entityByID.Tag as TalkClient;
             if (talkClient.FrontendConn != null)
             {
                 SendPacket op = SendPacket.Create <WhisperFailMessage>(new WhisperFailMessage(args.ToName, "GameUI_Heroes_Chat_Whisper_Not_Online"));
                 talkClient.FrontendConn.RequestOperation(op);
             }
         }
     }
 }
예제 #4
0
        public bool WhipserResultToGameClient(long cid, int resultNo, string receiverName)
        {
            Log <TalkService> .Logger.InfoFormat("WhipserResultToGameClient is called. [ cid:{0}, result:{1}, receiver:{2} ]", cid, resultNo, receiverName);

            IEntity entityByID = base.GetEntityByID(cid);

            if (entityByID == null)
            {
                if (base.LookUp.GetLocationCount(base.Category) > 1)
                {
                    int num = this.FindServiceID(cid, base.Category);
                    if (num > 0 && base.ID != num)
                    {
                        base.RequestOperation(num, new WhisperResultToGameClient(cid, resultNo, receiverName));
                        return(true);
                    }
                }
                Log <TalkService> .Logger.WarnFormat("WhipserResultToGameClient the end of the function", new object[0]);

                return(false);
            }
            TalkClient talkClient = entityByID.Tag as TalkClient;

            if (talkClient != null && talkClient.FrontendConn != null)
            {
                if (resultNo == 11)
                {
                    talkClient.FrontendConn.RequestOperation(SendPacket.Create <WhisperFailMessage>(new WhisperFailMessage(receiverName, "GameUI_Heroes_Chat_Whisper_Not_Online")));
                }
                else
                {
                    Log <TalkService> .Logger.ErrorFormat("WhipserResultToGameClient Unknown ResultNo : {0}", resultNo);
                }
                return(true);
            }
            Log <TalkService> .Logger.WarnFormat("WhipserResultToGameClient TalkClient is null.", new object[0]);

            return(false);
        }