public void RemoveActor(global::System.UInt64 actorId, global::System.Action <global::Fenix.Common.DefaultErrCode> callback) { var toHostId = Global.IdManager.GetHostIdByActorId(this.toActorId, this.isClient); if (this.FromHostId == toHostId) { var protoCode = OpCode.REMOVE_ACTOR_REQ; if (protoCode < OpCode.CALL_ACTOR_METHOD) { var peer = Global.NetManager.GetPeerById(this.FromHostId, this.NetType); var context = new RpcContext(null, peer); Global.Host.CallMethodWithParams(protoCode, new object[] { actorId, callback, context }); } else { Global.Host.GetActor(this.toActorId).CallMethodWithParams(protoCode, new object[] { actorId, callback }); } return; } Task.Run(() => { var msg = new __Fenix__Host__RemoveActorReq() { actorId = actorId }; var cb = new Action <byte[]>((cbData) => { var cbMsg = cbData == null?new __Fenix__Host__RemoveActorReq.Callback():global::Fenix.Common.Utils.RpcUtil.Deserialize <__Fenix__Host__RemoveActorReq.Callback>(cbData); callback?.Invoke(cbMsg.code); }); this.CallRemoteMethod(OpCode.REMOVE_ACTOR_REQ, msg, cb); }); }
public async Task <__Fenix__Host__RemoveActorReq.Callback> RemoveActorAsync(global::System.UInt64 actorId, global::System.Action <global::Fenix.Common.DefaultErrCode> callback = null) { var t = new TaskCompletionSource <__Fenix__Host__RemoveActorReq.Callback>(); var toHostId = Global.IdManager.GetHostIdByActorId(this.toActorId, this.isClient); if (this.FromHostId == toHostId) { global::System.Action <global::Fenix.Common.DefaultErrCode> _cb = (code) => { var cbMsg = new __Fenix__Host__RemoveActorReq.Callback(); cbMsg.code = code; callback?.Invoke(cbMsg.code); t.TrySetResult(cbMsg); }; var protoCode = OpCode.REMOVE_ACTOR_REQ; if (protoCode < OpCode.CALL_ACTOR_METHOD) { var peer = Global.NetManager.GetPeerById(this.FromHostId, this.NetType); var context = new RpcContext(null, peer); Global.Host.CallMethodWithParams(protoCode, new object[] { actorId, _cb, context }); } else { Global.Host.GetActor(this.toActorId).CallMethodWithParams(protoCode, new object[] { actorId, _cb }); } } else { Action <__Fenix__Host__RemoveActorReq.Callback> _cb = (cbMsg) => { callback?.Invoke(cbMsg.code); t.TrySetResult(cbMsg); }; await Task.Run(() => { var msg = new __Fenix__Host__RemoveActorReq() { actorId = actorId }; var cb = new Action <byte[]>((cbData) => { var cbMsg = cbData == null ? new __Fenix__Host__RemoveActorReq.Callback() : global::Fenix.Common.Utils.RpcUtil.Deserialize <__Fenix__Host__RemoveActorReq.Callback>(cbData); _cb?.Invoke(cbMsg); }); this.CallRemoteMethod(OpCode.REMOVE_ACTOR_REQ, msg, cb); }); } return(await t.Task); }