Exemplo n.º 1
0
        private static async Task DispatchDeltaAsync(Control control, Bitmap bitmap, IProtocolStream stream)
        {
            var buffer = await stream.ReceiveAsync();

            control.Invoke(new Action(() =>
            {
                int len = buffer.DecompressQuick(_bufferUncompressed);

                ProcessDelta(bitmap, _bufferUncompressed, 0, len);

                control.Refresh();
            }));
        }
Exemplo n.º 2
0
        public IProtocol Initialize(IMinecraftClient client, INetworkTCP tcp, bool debugPackets = false)
        {
            _minecraft  = client;
            _stream     = new ClassicStream(tcp);
            SavePackets = debugPackets;

            PacketsReceived = new List <IPacket>();
            PacketsSended   = new List <IPacket>();

            SendingAsyncHandlers = new Dictionary <Type, Func <ISendingAsyncArgs, Task> >();
            RegisterSupportedSendings();

            return(this);
        }
Exemplo n.º 3
0
        /// <summary>
        /// Packets are handled here. Compression and encryption are handled here too
        /// </summary>
        /// <param name="id">Packet ID</param>
        /// <param name="stream"></param>
        private void HandlePacket(int id, IProtocolStream stream)
        {
            using (var reader = new TrueCraftDataReader(stream as Stream))
            {
                IPacket packet = null;

                switch (State)
                {
                    #region Login

                case ConnectionState.Joining:
                    if (ServerResponse.JoiningServer[id] == null)
                    {
                        throw new ProtocolException("Reading error: Wrong Login packet ID.");
                    }

                    packet = ServerResponse.JoiningServer[id]().ReadPacket(reader);

                    OnPacketHandled(id, packet, ConnectionState.Joining);
                    break;

                    #endregion Login

                    #region Play

                case ConnectionState.Joined:
                    if (ServerResponse.JoinedServer[id] == null)
                    {
                        throw new ProtocolException("Reading error: Wrong Play packet ID.");
                    }

                    packet = ServerResponse.JoinedServer[id]().ReadPacket(reader);

                    OnPacketHandled(id, packet, ConnectionState.Joined);
                    break;

                    #endregion Play
                }

                if (SavePackets)
                {
                    PacketsReceived.Add(packet);
                }
            }
        }
Exemplo n.º 4
0
 public IProtocol GetProtocol(IProtocolStream protocolStream)
 {
     return new HyperProtocol(protocolStream);
 }
Exemplo n.º 5
0
        public IPacket WritePacket(IProtocolStream stream)
        {
            Coordinates.ToStreamShort(stream);

            return(this);
        }
Exemplo n.º 6
0
 public IPacket WritePacket(IProtocolStream stream)
 {
     // This space intentionally left blank
     return(this);
 }
Exemplo n.º 7
0
        public IPacket WritePacket(IProtocolStream stream)
        {
            stream.WriteString(Reason);

            return(this);
        }
Exemplo n.º 8
0
        public IPacket WritePacket(IProtocolStream stream)
        {
            stream.WriteString(Username);

            return(this);
        }
Exemplo n.º 9
0
        public IPacket WritePacket(IProtocolStream stream)
        {
            stream.WriteByte(SupportLevel);

            return(this);
        }
Exemplo n.º 10
0
        public IPacket WritePacket(IProtocolStream stream)
        {
            stream.WriteByte((byte)WeatherType);

            return(this);
        }
        public IPacket WritePacket(IProtocolStream stream)
        {
            stream.WriteShort(Distance);

            return(this);
        }
Exemplo n.º 12
0
        public IPacket WritePacket(IProtocolStream stream)
        {
            stream.WriteString(ConnectionHash);

            return(this);
        }
Exemplo n.º 13
0
 public IPacket WritePacket(IProtocolStream stream)
 {
     return(this);
 }
Exemplo n.º 14
0
 public IProtocol GetProtocol(IProtocolStream protocolStream)
 {
     return new SimpleProtocol(protocolStream);
 }
Exemplo n.º 15
0
 public DebugStream(IProtocolStream protocolStream)
 {
     _protocolStream = protocolStream;
 }
Exemplo n.º 16
0
        public IPacket WritePacket(IProtocolStream stream)
        {
            stream.WriteByte(SelectionID);

            return(this);
        }
Exemplo n.º 17
0
 public HyperProtocol(IProtocolStream protocolStream)
 {
     _protocolStream = protocolStream;
 }
Exemplo n.º 18
0
        public IPacket WritePacket(IProtocolStream stream)
        {
            stream.WriteSByte(PlayerID);

            return(this);
        }
Exemplo n.º 19
0
 public SimpleProtocol(IProtocolStream protocolStream)
 {
     _protocolStream = protocolStream;
 }
        public IPacket WritePacket(IProtocolStream stream)
        {
            stream.WriteShort(NameID);

            return(this);
        }