public static ETTask <IActorResponse> Call(this ActorMessageSenderComponent self, long actorId, IActorRequest message, bool exception = true) { if (actorId == 0) { throw new Exception($"actor id is 0: {MongoHelper.ToJson(message)}"); } var tcs = new ETTaskCompletionSource <IActorResponse>(); int process = IdGenerater.GetProcess(actorId); string address = StartProcessConfigCategory.Instance.Get(process).InnerAddress; Session session = NetInnerComponent.Instance.Get(address); InstanceIdStruct instanceIdStruct = new InstanceIdStruct(actorId); instanceIdStruct.Process = IdGenerater.Process; message.ActorId = instanceIdStruct.ToLong(); message.RpcId = ++self.RpcId; self.requestCallback.Add(message.RpcId, new ActorMessageSender((response) => { if (exception && ErrorCode.IsRpcNeedThrowException(response.Error)) { tcs.SetException(new Exception($"Rpc error: {MongoHelper.ToJson(response)}")); return; } tcs.SetResult(response); })); session.Send(message); return(tcs.Task); }
public void EndInit() { this.Type = EnumHelper.FromString <SceneType>(this.SceneType); InstanceIdStruct instanceIdStruct = new InstanceIdStruct(this.Process, (uint)this.Id); this.SceneId = instanceIdStruct.ToLong(); }
public static long GenerateInstanceId() { InstanceIdStruct instanceIdStruct = new InstanceIdStruct(process, ++MaxConfigSceneId); return(instanceIdStruct.ToLong()); }
// Scene的InstanceId跟Id一样 public static long GenerateProcessSceneId() { InstanceIdStruct instanceIdStruct = new InstanceIdStruct(process, 0); return(instanceIdStruct.ToLong()); }