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); }
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); }
public abstract bool RegisterHandler(NFGUID xID, NFIActor.Handler handler);
public abstract NFGUID CreateActor(NFIActor.Handler handler);