Exemple #1
0
        public async Task <__ServerGModule__MatchService__FindMatchReq.Callback> rpc_find_match_async(global::System.String uid, global::System.Action <global::Shared.Protocol.ErrCode, global::Server.DataModel.Account> callback = null)
#endif
        {
#if FENIX_CODEGEN
#if !RUNTIME
            var t = new TaskCompletionSource <dynamic>();
#else
            var t = new TaskCompletionSource <__ServerGModule__MatchService__FindMatchReq.Callback>();
#endif
#else
            var t        = new TaskCompletionSource <__ServerGModule__MatchService__FindMatchReq.Callback>();
            var toHostId = Global.IdManager.GetHostIdByActorId(this.toActorId, this.isClient);
            if (this.FromHostId == toHostId)
            {
                global::System.Action <global::Shared.Protocol.ErrCode, global::Server.DataModel.Account> _cb = (code, user) =>
                {
                    var cbMsg = new __ServerGModule__MatchService__FindMatchReq.Callback();
                    cbMsg.code = code;
                    cbMsg.user = user;
                    callback?.Invoke(cbMsg.code, cbMsg.user);
                    t.TrySetResult(cbMsg);
                };
                var protoCode = ProtocolCode.__SERVERGMODULE__MATCHSERVICE__FIND_MATCH_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[] { uid, _cb, context });
                }
                else
                {
                    Global.Host.GetActor(this.toActorId).CallMethodWithParams(protoCode, new object[] { uid, _cb });
                }
            }
            else
            {
                Action <__ServerGModule__MatchService__FindMatchReq.Callback> _cb = (cbMsg) =>
                {
                    callback?.Invoke(cbMsg.code, cbMsg.user);
                    t.TrySetResult(cbMsg);
                };
                await Task.Run(() => {
                    var msg = new __ServerGModule__MatchService__FindMatchReq()
                    {
                        uid = uid
                    };
                    var cb = new Action <byte[]>((cbData) => {
                        var cbMsg = cbData == null ? new __ServerGModule__MatchService__FindMatchReq.Callback() : global::Fenix.Common.Utils.RpcUtil.Deserialize <__ServerGModule__MatchService__FindMatchReq.Callback>(cbData);
                        _cb?.Invoke(cbMsg);
                    });
                    this.CallRemoteMethod(ProtocolCode.__SERVERGMODULE__MATCHSERVICE__FIND_MATCH_REQ, msg, cb);
                });
            }
#endif
            return(await t.Task);
        }
Exemple #2
0
        public void SERVER_ONLY__ServerGModule__MatchService__find_match(IMessage msg, Action <IMessage> cb)
        {
            var _msg = (__ServerGModule__MatchService__FindMatchReq)msg;

            this.FindMatch(_msg.uid, (code, user) =>
            {
                var cbMsg  = new __ServerGModule__MatchService__FindMatchReq.Callback();
                cbMsg.code = code;
                cbMsg.user = user;
                cb.Invoke(cbMsg);
            });
        }
Exemple #3
0
        public void SERVER_ONLY__ServerGModule__MatchService__find_match(IMessage msg, Action <IMessage> cb)
        {
#if ENABLE_IL2CPP || !DEBUG || RUNTIME
            var _msg = (__ServerGModule__MatchService__FindMatchReq)msg;
            this.FindMatch(_msg.uid, (code, user) =>
            {
                var cbMsg  = new __ServerGModule__MatchService__FindMatchReq.Callback();
                cbMsg.code = code;
                cbMsg.user = user;
                cb.Invoke(cbMsg);
            });
#else
            dynamic _msg = msg;
            self.FindMatch(_msg.uid, (global::System.Action <global::Shared.Protocol.ErrCode, global::Server.DataModel.Account>)((code, user) =>
            {
                dynamic cbMsg = new __ServerGModule__MatchService__FindMatchReq.Callback();
                cbMsg.code    = code;
                cbMsg.user    = user;
                cb.Invoke(cbMsg);
            }));
#endif
        }