Example #1
0
        public void rpc_create_account(global::System.String username, global::System.String password, global::System.Action <global::Shared.Protocol.ErrCode> callback)
        {
            var toHostId = Global.IdManager.GetHostIdByActorId(this.toActorId, this.isClient);

            if (this.FromHostId == toHostId)
            {
                var protoCode = ProtocolCode.__SERVERGMODULE__LOGINSERVICE__CREATE_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, callback, context });
                }
                else
                {
                    Global.Host.GetActor(this.toActorId).CallMethodWithParams(protoCode, new object[] { username, password, callback });
                }
                return;
            }
            Task.Run(() => {
                var msg = new __ServerGModule__LoginService__CreateAccountReq()
                {
                    username = username,
                    password = password
                };
                var cb = new Action <byte[]>((cbData) => {
                    var cbMsg = cbData == null?new __ServerGModule__LoginService__CreateAccountReq.Callback():global::Fenix.Common.Utils.RpcUtil.Deserialize <__ServerGModule__LoginService__CreateAccountReq.Callback>(cbData);
                    callback?.Invoke(cbMsg.code);
                });
                this.CallRemoteMethod(ProtocolCode.__SERVERGMODULE__LOGINSERVICE__CREATE_ACCOUNT_REQ, msg, cb);
            });
        }
Example #2
0
        public async Task <__ServerGModule__LoginService__CreateAccountReq.Callback> rpc_create_account_async(global::System.String username, global::System.String password, global::System.Action <global::Shared.Protocol.ErrCode> callback = null)
#endif
        {
#if FENIX_CODEGEN
#if !RUNTIME
            var t = new TaskCompletionSource <dynamic>();
#else
            var t = new TaskCompletionSource <__ServerGModule__LoginService__CreateAccountReq.Callback>();
#endif
#else
            var t        = new TaskCompletionSource <__ServerGModule__LoginService__CreateAccountReq.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 __ServerGModule__LoginService__CreateAccountReq.Callback();
                    cbMsg.code = code;
                    callback?.Invoke(cbMsg.code);
                    t.TrySetResult(cbMsg);
                };
                var protoCode = ProtocolCode.__SERVERGMODULE__LOGINSERVICE__CREATE_ACCOUNT_REQ;
                if (Math.Abs(protoCode) < OpCode.CALL_ACTOR_METHOD)
                {
                    var peer    = Global.NetManager.GetRemotePeerById(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 <__ServerGModule__LoginService__CreateAccountReq.Callback> _cb = (cbMsg) =>
                {
                    callback?.Invoke(cbMsg.code);
                    t.TrySetResult(cbMsg);
                };
                await Task.Run(() => {
                    var msg = new __ServerGModule__LoginService__CreateAccountReq()
                    {
                        username = username,
                        password = password
                    };
                    var cb = new Action <byte[]>((cbData) => {
                        var cbMsg = cbData == null ? new __ServerGModule__LoginService__CreateAccountReq.Callback() : global::Fenix.Common.Utils.RpcUtil.Deserialize <__ServerGModule__LoginService__CreateAccountReq.Callback>(cbData);
                        _cb?.Invoke(cbMsg);
                    });
                    this.CallRemoteMethod(ProtocolCode.__SERVERGMODULE__LOGINSERVICE__CREATE_ACCOUNT_REQ, msg, cb);
                });
            }
#endif
            return(await t.Task);
        }