Example #1
0
        public override NFIDENTID CreateActor(NFIActor.Handler handler)
        {
            NFIDENTID xID    = new NFIDENTID(0, ++mnActorIndex);
            NFIActor  xActor = new NFCActor(xID, this);

            //添加仍旧有问题,foreach中万一有其他线程添加
            bool bRet = mxActorDic.TryAdd(xID, xActor);

            if (bRet)
            {
                if (null != handler)
                {
                    RegisterHandler(xID, handler);

                    NFIActorMessage xMessage = new NFIActorMessage();
                    xMessage.bAsync  = false; //同步消息
                    xMessage.bReturn = false; //无需返回

                    xMessage.eType = NFIActorMessage.EACTOR_MESSAGE_ID.EACTOR_INIT;
                    SendMsg(xActor.GetAddress(), null, xMessage);

                    xMessage.eType = NFIActorMessage.EACTOR_MESSAGE_ID.EACTOR_AFTER_INIT;
                    SendMsg(xActor.GetAddress(), null, xMessage);
                }

                return(xID);
            }

            return(null);
        }
Example #2
0
        public override bool RegisterHandler(NFIDENTID xID, NFIActor.Handler handler)
        {
            if (null == xID || null == handler)
            {
                return(false);
            }

            NFIActor xActor = GetActor(xID);

            if (null != xActor)
            {
                xActor.RegisterHandler(handler);

                return(true);
            }

            return(false);
        }
Example #3
0
 public abstract bool RegisterHandler(NFGUID xID, NFIActor.Handler handler);
Example #4
0
 public abstract NFGUID CreateActor(NFIActor.Handler handler);