public void SERVER_API_delete_account(IMessage msg, Action <object> cb) { var _msg = (DeleteAccountReq)msg; this.DeleteAccount(_msg.username, _msg.password, (code) => { var cbMsg = new DeleteAccountReq.Callback(); cbMsg.code = code; cb.Invoke(cbMsg); }); }
public async Task <DeleteAccountReq.Callback> rpc_delete_account_async(global::System.String username, global::System.String password, global::System.Action <global::Shared.Protocol.ErrCode> callback = null) { var t = new TaskCompletionSource <DeleteAccountReq.Callback>(); var toHostId = Global.IdManager.GetHostIdByActorId(this.toActorId, this.isClient); if (this.FromHostId == toHostId) { global::System.Action <global::Shared.Protocol.ErrCode> _cb = (code) => { var cbMsg = new DeleteAccountReq.Callback(); cbMsg.code = code; callback?.Invoke(cbMsg.code); t.TrySetResult(cbMsg); }; var protoCode = ProtocolCode.DELETE_ACCOUNT_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[] { username, password, _cb, context }); } else { Global.Host.GetActor(this.toActorId).CallMethodWithParams(protoCode, new object[] { username, password, _cb }); } } else { Action <DeleteAccountReq.Callback> _cb = (cbMsg) => { callback?.Invoke(cbMsg.code); t.TrySetResult(cbMsg); }; await Task.Run(() => { var msg = new DeleteAccountReq() { username = username, password = password }; var cb = new Action <byte[]>((cbData) => { var cbMsg = cbData == null ? new DeleteAccountReq.Callback() : RpcUtil.Deserialize <DeleteAccountReq.Callback>(cbData); _cb?.Invoke(cbMsg); }); this.CallRemoteMethod(ProtocolCode.DELETE_ACCOUNT_REQ, msg, cb); }); } return(await t.Task); }