public void ReadFromStream(IPacketCodec content) { EntityId = content.ReadVarInt(); PlayerUuid = content.ReadUuid(); Position = content.ReadVector3d(); Rotation = content.ReadAngleRotation(); }
public void ReadFromStream(IPacketCodec rawCodec, PacketBoundTo boundTo, Func <int> compressThresholdCallback, Func <ProtocolState> stateCallback) { BoundTo = boundTo; State = stateCallback(); var length = rawCodec.ReadVarInt(); // Length of Packet ID + Data PacketLength = length; var threshold = compressThresholdCallback(); int dataLength; using var recvStream = new MemoryStream(); //no extra bytes read rawCodec.CopyTo(recvStream, length); var recvCodec = rawCodec.Clone(recvStream); recvStream.Position = 0; if (threshold == 0 || (dataLength = recvCodec.ReadVarInt()) < threshold) { DataLength = length; recvCodec.CopyTo(BaseStream, length); BaseStream.Position = 0; PacketId = Content.ReadVarInt(); return; } DataLength = dataLength; using var compressedStream = new InflaterInputStream(recvStream) { IsStreamOwner = false }; rawCodec.Clone(compressedStream).CopyTo(BaseStream, dataLength); BaseStream.Position = 0; PacketId = Content.ReadVarInt(); }
public void WriteToStream(IPacketCodec content) { content.WriteVarInt(EntityId); content.Write(PlayerUuid); content.Write(Position); content.WriteAngleRotation(Rotation); }
public void WriteToStream(IPacketCodec content) { content.WriteVarInt(ProtocolVersion); content.Write(ServerAddress); content.Write(ServerPort); content.WriteVarIntEnum(NextState); }
public void ReadFromStream(IPacketCodec content) { ProtocolVersion = content.ReadVarInt(); ServerAddress = content.ReadString(); ServerPort = content.ReadUInt16(); NextState = content.ReadVarIntEnum <ProtocolState>(); }
public void WriteToStream(IPacketCodec rawCodec, Func <int> compressThresholdCallback) { var threshold = compressThresholdCallback(); if (threshold == 0 || DataLength < threshold) { PacketLength = (int)BaseStream.Length; rawCodec.WriteVarInt(DataLength); Content.CopyTo(rawCodec.BaseStream, DataLength); return; } var stream = new MemoryStream(); var content = Content.Clone(stream); content.WriteVarInt(DataLength); var compressedStream = new DeflaterOutputStream(stream); Content.CopyTo(compressedStream, DataLength); compressedStream.Flush(); stream.Position = 0; PacketLength = (int)stream.Length; rawCodec.WriteVarInt(PacketLength); content.CopyTo(rawCodec.BaseStream, PacketLength); compressedStream.Dispose(); stream.Dispose(); }
public void ReadFromStream(IPacketCodec content) { EntityId = content.ReadVarInt(); Position = content.ReadVector3d(); Rotation = content.ReadAngleRotation(); OnGround = content.ReadBoolean(); }
public DotNettyListenerAdapter(ListenerOptions options, IServiceProvider serviceProvider) { _options = options; _serviceProvider = serviceProvider; InternalLoggerFactory.DefaultFactory = _serviceProvider.GetService <ILoggerFactory>(); _packetCodec = _serviceProvider.GetRequiredService <IPacketCodec>(); }
public void WriteToStream(IPacketCodec content) { content.WriteVarInt(EntityId); content.Write((short)(Delta.X * 4096)); content.Write((short)(Delta.Y * 4096)); content.Write((short)(Delta.Z * 4096)); content.Write(OnGround); }
public void WriteToStream(IPacketCodec content) { content.Write(Locale); content.Write(ViewDistance); content.WriteVarIntEnum(ChatMode); content.Write(ChatColors); content.Write(DisplayedSkinParts); content.WriteVarIntEnum(MainHand); content.Write(DisableTextFiltering); }
public void ReadFromStream(IPacketCodec content) { Locale = content.ReadString(); ViewDistance = content.ReadSByte(); ChatMode = content.ReadVarIntEnum <ChatMode>(); ChatColors = content.ReadBoolean(); DisplayedSkinParts = content.ReadEnum <SkinPart>(); MainHand = content.ReadVarIntEnum <HandSide>(); DisableTextFiltering = content.ReadBoolean(); }
public void ReadFromStream(IPacketCodec content) { EntityId = content.ReadVarInt(); var delta = new Vector3d { X = content.ReadInt16(), Y = content.ReadInt16(), Z = content.ReadInt16() }; delta *= 0.000244140625 /* 1/4096 */; Delta = delta; OnGround = content.ReadBoolean(); }
public DotNettyMessageDecoder(IPacketCodec packetCodec) : base(packetCodec.IsLittleEndian ? ByteOrder.LittleEndian : ByteOrder.BigEndian, ushort.MaxValue, packetCodec.LengthFieldOffset, packetCodec.LengthFieldLength, packetCodec.HeaderLenght - packetCodec.LengthFieldOffset - packetCodec.LengthFieldLength, 0, true) { _packetCodec = packetCodec; }
public WebSocketServerHandler(IServiceProvider serviceProvider, ListenerOptions netListenerOptions) { this._appSessionContainer = serviceProvider.GetRequiredService <AppSessionContainer <AppSession> >(); this._serviceProvider = serviceProvider ?? throw new ArgumentNullException(nameof(serviceProvider)); this._netListenerOptions = netListenerOptions ?? throw new ArgumentNullException(nameof(netListenerOptions)); this._commandContainer = serviceProvider.GetRequiredService <ICommandDescriptorContainer>(); this._commandActivator = serviceProvider.GetRequiredService <ICommandActivator>(); this._packetCodec = serviceProvider.GetRequiredService <IPacketCodec>(); ILoggerFactory loggerFactory = serviceProvider.GetRequiredService <ILoggerFactory>(); _logger = loggerFactory.CreateLogger <WebSocketServerHandler>(); }
public void ReadFromStream(IPacketCodec content) { Position = content.ReadVector3d(); Rotation = content.ReadRotation(); var flags = content.ReadSByte(); XKind = (CoordKind)(flags & 0x01); YKind = (CoordKind)(flags >> 1 & 0x01); ZKind = (CoordKind)(flags >> 2 & 0x01); YRotKind = (CoordKind)(flags >> 3 & 0x01); XRotKind = (CoordKind)(flags >> 4 & 0x01); TeleportId = content.ReadVarInt(); DismountVehicle = content.ReadBoolean(); }
public void WriteToStream(IPacketCodec content) { content.WriteVarInt(EntityId); content.WriteVarIntEnum(Type); if (Type == InteractType.InteractAt) { content.Write(Target); } if (Type == InteractType.Interact || Type == InteractType.InteractAt) { content.WriteVarIntEnum(Hand); } content.Write(Sneaking); }
public void ReadFromStream(IPacketCodec content) { EntityId = content.ReadVarInt(); Type = content.ReadVarIntEnum <InteractType>(); if (Type == InteractType.InteractAt) { Target = content.ReadVector3(); } if (Type == InteractType.Interact || Type == InteractType.InteractAt) { Hand = content.ReadVarIntEnum <Hand>(); } Sneaking = content.ReadBoolean(); }
public void ReadFromStream(IPacketCodec content) { EntityId = content.ReadInt32(); IsHardcore = content.ReadBoolean(); Gamemode = content.ReadEnum <Gamemode>(); PreviousGamemode = content.ReadEnum <Gamemode>(); WorldCount = content.ReadVarInt(); WorldNames = content.ReadIdentifiers(WorldCount); DimensionCodec = content.ReadNbtTag <NbtCompound>(); Dimension = content.ReadNbtTag <NbtCompound>(); WorldName = content.ReadString(); HashedSeed = content.ReadInt64(); MaxPlayers = content.ReadVarInt(); ViewDistance = content.ReadVarInt(); ReducedDebugInfo = content.ReadBoolean(); EnableRespawnScreen = content.ReadBoolean(); IsDebug = content.ReadBoolean(); IsFlat = content.ReadBoolean(); }
public void WriteToStream(IPacketCodec content) { content.Write(EntityId); content.Write(IsHardcore); content.Write(Gamemode); content.Write(PreviousGamemode); content.WriteVarInt(WorldCount); content.Write(WorldNames); content.Write(DimensionCodec); content.Write(Dimension); content.Write(WorldName); content.Write(HashedSeed); content.WriteVarInt(MaxPlayers); content.Write(ViewDistance); content.Write(ReducedDebugInfo); content.Write(EnableRespawnScreen); content.Write(IsDebug); content.Write(IsFlat); }
public void ReadFromStream(IPacketCodec content) { #if FixEndOfStream try { JsonData = content.ReadString(); Position = content.ReadEnum <ChatMessagePosition>(); Sender = content.ReadUuid(); } catch { // ignore } #else JsonData = content.ReadString(); Position = content.ReadEnum <ChatMessagePosition>(); Sender = content.ReadUuid(); #endif }
public void WriteToStream(IPacketCodec content) { byte flags = 0; void PushFlag(CoordKind kind) { flags |= (byte)(flags << 1 & (byte)kind); } PushFlag(XKind); PushFlag(YKind); PushFlag(ZKind); PushFlag(YRotKind); PushFlag(XRotKind); content.Write(Position); content.Write(Rotation); content.Write(flags); content.WriteVarInt(TeleportId); content.Write(DismountVehicle); }
public void WriteToStream(IPacketCodec content) { content.Write(Message); }
public void ReadFromStream(IPacketCodec content) { Message = content.ReadString(); }
public void WriteToStream(IPacketCodec content) { content.Write(KeepAliveId); }
public void ReadFromStream(IPacketCodec content) { KeepAliveId = content.ReadInt64(); }
public void WriteToStream(IPacketCodec content) { content.WriteVarInt(Threshold); }
public void ReadFromStream(IPacketCodec content) { Threshold = content.ReadVarInt(); }
public void WriteToStream(IPacketCodec content) { //empty }
public void ReadFromStream(IPacketCodec content) { //empty }
public void WriteToStream(IPacketCodec content) { content.WriteVarInt(EntityId); content.WriteAngleRotation(Rotation); content.Write(OnGround); }