Example #1
0
        internal RPCResult <T> CreateResult <T>()
        {
            RPCResult <T> result = new RPCResult <T>();

            result.ReturnIndex = ++resultReturnIndexCounter;
            return(result);
        }
Example #2
0
        internal void Invoke(IEnumerable <Player> players, RPCResult result, string name, params object[] args)
        {
            Network.ByteOutStream stream = new Network.ByteOutStream(256);

            stream.WriteByte(HeaderBytes.RemoteProcedureCall);
            stream.WriteBool(true);
            stream.WriteString(name);

            if (result != null)
            {
                stream.WriteInt(result.ReturnIndex);
                results.Add(result.ReturnIndex, result);
                result.Name = name;
            }

            foreach (object arg in args)
            {
                Writer writer;

                if (!writers.TryGetValue(arg.GetType(), out writer))
                {
                    log.Error("No RPC argument writer for type '{0}', can't send RPC '{1}'", arg.GetTypeName(), name);
                    return;
                }

                writer(stream, arg.GetType(), arg);
            }

            log.Info("Sending {0}", name);

            foreach (Player player in players)
            {
                player.Connection.Queue(stream, true);
            }
        }
Example #3
0
        public RPCResult <R> InvokeOn(Player player)
        {
            RPCResult <R> result = RPC.CreateResult <R>();

            RPC.Invoke(new[] { player }, result, Name);

            return(result);
        }