Esempio n. 1
0
        private static MemoryBuffer GetBroadcastBuffer(AppBroadcast broadcast)
        {
            MemoryBuffer memoryBuffer = new MemoryBuffer(65536);

            Stream.SetData(memoryBuffer.Data, 0, memoryBuffer.Length);
            AppMessage appMessage = Facepunch.Pool.Get <AppMessage>();

            appMessage.broadcast = broadcast;
            appMessage.ToProto(Stream);
            if (appMessage.ShouldPool)
            {
                appMessage.Dispose();
            }
            return(memoryBuffer.Slice((int)Stream.Position));
        }
Esempio n. 2
0
        public void Send(AppResponse response)
        {
            AppMessage appMessage = Facepunch.Pool.Get <AppMessage>();

            appMessage.response    = response;
            MessageStream.Position = 0L;
            appMessage.ToProto(MessageStream);
            int num = (int)MessageStream.Position;

            MessageStream.Position = 0L;
            MemoryBuffer memoryBuffer = new MemoryBuffer(num);

            MessageStream.Read(memoryBuffer.Data, 0, num);
            if (appMessage.ShouldPool)
            {
                appMessage.Dispose();
            }
            SendRaw(memoryBuffer.Slice(num));
        }