Ejemplo n.º 1
0
        public override int ProcessModuleRedirectRequest(ModuleRedirect rpc)
        {
            try
            {
                // replace RootProcedure.ActionName. 为了统计和日志输出。
                Transaction.Current.TopProcedure.ActionName = rpc.Argument.MethodFullName;

                rpc.Result.ModuleId       = rpc.Argument.ModuleId;
                rpc.Result.AutoKeyLocalId = App.Zeze.Config.AutoKeyLocalId;
                if (false == Game.ModuleRedirect.Instance.Handles.TryGetValue(rpc.Argument.MethodFullName, out var handle))
                {
                    rpc.SendResultCode(ModuleRedirect.ResultCodeMethodFullNameNotFound);
                    return(Procedure.LogicError);
                }
                var(ReturnCode, Params) = handle(rpc.SessionId, rpc.Argument.HashCode, rpc.Argument.Params, rpc.Result.Actions);
                rpc.Result.ReturnCode   = ReturnCode;
                if (ReturnCode == Procedure.Success)
                {
                    rpc.Result.Params = Params;
                }
                // rpc 成功了,具体handle结果还需要看ReturnCode。
                rpc.SendResultCode(ModuleRedirect.ResultCodeSuccess);
                return(rpc.Result.ReturnCode);
            }
            catch (Exception)
            {
                rpc.SendResultCode(ModuleRedirect.ResultCodeHandleException);
                throw;
            }
        }
Ejemplo n.º 2
0
        public override int ProcessModuleRedirectRequest(ModuleRedirect rpc)
        {
            long SourceProvider = rpc.Sender.SessionId;
            long provider;

            if (ChoiceProvider(rpc.Argument.ServiceNamePrefix, rpc.Argument.ModuleId, rpc.Argument.HashCode, out provider))
            {
                rpc.Send(App.ProviderService.GetSocket(provider), (context) =>
                {
                    // process result。context == rpc
                    if (rpc.IsTimeout)
                    {
                        rpc.ResultCode = ModuleRedirect.ResultCodeLinkdTimeout;
                    }

                    rpc.Send(App.ProviderService.GetSocket(SourceProvider)); // send back to src provider
                    return(Zeze.Transaction.Procedure.Success);
                });
                // async mode
            }
            else
            {
                rpc.SendResultCode(ModuleRedirect.ResultCodeLinkdNoProvider); // send back direct
            }
            return(Zeze.Transaction.Procedure.Success);
        }