Пример #1
0
        private bool CheckAndProcessRpc(MethodDefinition md)
        {
            try
            {
                if (md.TryGetCustomAttribute <ServerRpcAttribute>(out CustomAttribute serverAttribute))
                {
                    if (md.HasCustomAttribute <ClientRpcAttribute>())
                    {
                        throw new RpcException("Method should not have both ServerRpc and ClientRpc", md);
                    }

                    // todo make processRpc return the found Rpc instead of saving it to hidden list
                    serverRpcProcessor.ProcessRpc(md, serverAttribute);
                    return(true);
                }
                else if (md.TryGetCustomAttribute <ClientRpcAttribute>(out CustomAttribute clientAttribute))
                {
                    // todo make processRpc return the found Rpc instead of saving it to hidden list
                    clientRpcProcessor.ProcessRpc(md, clientAttribute);
                    return(true);
                }
            }
            catch (RpcException e)
            {
                logger.Error(e);
            }

            return(false);
        }
Пример #2
0
        private RpcMethod CheckAndProcessRpc(MethodDefinition md, int index)
        {
            if (md.TryGetCustomAttribute <ServerRpcAttribute>(out var serverAttribute))
            {
                if (md.HasCustomAttribute <ClientRpcAttribute>())
                {
                    throw new RpcException("Method should not have both ServerRpc and ClientRpc", md);
                }

                return(serverRpcProcessor.ProcessRpc(md, serverAttribute, index));
            }
            else if (md.TryGetCustomAttribute <ClientRpcAttribute>(out var clientAttribute))
            {
                return(clientRpcProcessor.ProcessRpc(md, clientAttribute, index));
            }
            return(null);
        }