Пример #1
0
        public void SERVER_API__ServerGModule__LoginService__login(IMessage msg, Action <IMessage> cb)
        {
#if ENABLE_IL2CPP || !DEBUG || RUNTIME
            var _msg = (__ServerGModule__LoginService__LoginReq)msg;
            this.Login(_msg.username, _msg.password, _msg.extraData, (code, arg1, arg2, arg3, arg4) =>
            {
                var cbMsg  = new __ServerGModule__LoginService__LoginReq.Callback();
                cbMsg.code = code;
                cbMsg.arg1 = arg1;
                cbMsg.arg2 = arg2;
                cbMsg.arg3 = arg3;
                cbMsg.arg4 = arg4;
                cb.Invoke(cbMsg);
            });
#else
            dynamic _msg = msg;
            self.Login(_msg.username, _msg.password, _msg.extraData, (global::System.Action <global::Shared.Protocol.ErrCode, global::System.String, global::System.UInt64, global::System.String, global::System.String>)((code, arg1, arg2, arg3, arg4) =>
            {
                dynamic cbMsg = new __ServerGModule__LoginService__LoginReq.Callback();
                cbMsg.code    = code;
                cbMsg.arg1    = arg1;
                cbMsg.arg2    = arg2;
                cbMsg.arg3    = arg3;
                cbMsg.arg4    = arg4;
                cb.Invoke(cbMsg);
            }));
#endif
        }
Пример #2
0
        public async Task <__ServerGModule__LoginService__LoginReq.Callback> rpc_login_async(global::System.String username, global::System.String password, global::System.Action <global::Shared.Protocol.ErrCode, global::System.String, global::System.UInt64, global::System.String, global::System.String> callback = null)
        {
            var t        = new TaskCompletionSource <__ServerGModule__LoginService__LoginReq.Callback>();
            var toHostId = Global.IdManager.GetHostIdByActorId(this.toActorId, this.isClient);

            if (this.FromHostId == toHostId)
            {
                global::System.Action <global::Shared.Protocol.ErrCode, global::System.String, global::System.UInt64, global::System.String, global::System.String> _cb = (code, arg1, arg2, arg3, arg4) =>
                {
                    var cbMsg = new __ServerGModule__LoginService__LoginReq.Callback();
                    cbMsg.code = code;
                    cbMsg.arg1 = arg1;
                    cbMsg.arg2 = arg2;
                    cbMsg.arg3 = arg3;
                    cbMsg.arg4 = arg4;
                    callback?.Invoke(cbMsg.code, cbMsg.arg1, cbMsg.arg2, cbMsg.arg3, cbMsg.arg4);
                    t.TrySetResult(cbMsg);
                };
                var protoCode = ProtocolCode.__SERVERGMODULE__LOGINSERVICE__LOGIN_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 <__ServerGModule__LoginService__LoginReq.Callback> _cb = (cbMsg) =>
                {
                    callback?.Invoke(cbMsg.code, cbMsg.arg1, cbMsg.arg2, cbMsg.arg3, cbMsg.arg4);
                    t.TrySetResult(cbMsg);
                };
                await Task.Run(() => {
                    var msg = new __ServerGModule__LoginService__LoginReq()
                    {
                        username = username,
                        password = password
                    };
                    var cb = new Action <byte[]>((cbData) => {
                        var cbMsg = cbData == null ? new __ServerGModule__LoginService__LoginReq.Callback() : global::Fenix.Common.Utils.RpcUtil.Deserialize <__ServerGModule__LoginService__LoginReq.Callback>(cbData);
                        _cb?.Invoke(cbMsg);
                    });
                    this.CallRemoteMethod(ProtocolCode.__SERVERGMODULE__LOGINSERVICE__LOGIN_REQ, msg, cb);
                });
            }
            return(await t.Task);
        }
Пример #3
0
        public void SERVER_API__ServerGModule__LoginService__login(IMessage msg, Action <IMessage> cb)
        {
            var _msg = (__ServerGModule__LoginService__LoginReq)msg;

            this.Login(_msg.username, _msg.password, (code, arg1, arg2, arg3, arg4) =>
            {
                var cbMsg  = new __ServerGModule__LoginService__LoginReq.Callback();
                cbMsg.code = code;
                cbMsg.arg1 = arg1;
                cbMsg.arg2 = arg2;
                cbMsg.arg3 = arg3;
                cbMsg.arg4 = arg4;
                cb.Invoke(cbMsg);
            });
        }