public void SERVER_ONLY_remove_actor(IMessage msg, Action <IMessage> cb, RpcContext context) { var _msg = (RemoveActorReq)msg; this.RemoveActor(_msg.actorId, (code) => { var cbMsg = new RemoveActorReq.Callback(); cbMsg.code = code; cb.Invoke(cbMsg); }, context); }
public async Task <RemoveActorReq.Callback> RemoveActorAsync(global::System.UInt64 actorId, global::System.Action <global::Fenix.Common.DefaultErrCode> callback = null) { var t = new TaskCompletionSource <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 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 <RemoveActorReq.Callback> _cb = (cbMsg) => { callback?.Invoke(cbMsg.code); t.TrySetResult(cbMsg); }; await Task.Run(() => { var msg = new RemoveActorReq() { actorId = actorId }; var cb = new Action <byte[]>((cbData) => { var cbMsg = cbData == null ? new RemoveActorReq.Callback() : RpcUtil.Deserialize <RemoveActorReq.Callback>(cbData); _cb?.Invoke(cbMsg); }); this.CallRemoteMethod(OpCode.REMOVE_ACTOR_REQ, msg, cb); }); } return(await t.Task); }
public void SERVER_ONLY__Fenix__Host__remove_actor(IMessage msg, Action <IMessage> cb, RpcContext context) { #if ENABLE_IL2CPP || !DEBUG || RUNTIME var _msg = (RemoveActorReq)msg; this.RemoveActor(_msg.actorId, (code) => { var cbMsg = new RemoveActorReq.Callback(); cbMsg.code = code; cb.Invoke(cbMsg); }, context); #else dynamic _msg = msg; self.RemoveActor(_msg.actorId, (global::System.Action <global::Fenix.Common.DefaultErrCode>)((code) => { dynamic cbMsg = new RemoveActorReq.Callback(); cbMsg.code = code; cb.Invoke(cbMsg); }), context); #endif }