mirror of
https://gitlab.com/Syroot/Worms.git
synced 2025-04-09 19:00:06 +03:00
Support channel packet format.
This commit is contained in:
parent
1d8c090957
commit
7e801057ac
@ -74,7 +74,7 @@ namespace Syroot.Worms.OnlineWorms.Server
|
|||||||
EndPoint = new IPEndPoint(IPAddress.Loopback, 1),
|
EndPoint = new IPEndPoint(IPAddress.Loopback, 1),
|
||||||
Type = ChannelType.Normal,
|
Type = ChannelType.Normal,
|
||||||
Color = Color.LightGreen,
|
Color = Color.LightGreen,
|
||||||
UserLoad = 5
|
Load = ChannelLoad.Highest
|
||||||
},
|
},
|
||||||
new ChannelInfo
|
new ChannelInfo
|
||||||
{
|
{
|
||||||
@ -87,7 +87,7 @@ namespace Syroot.Worms.OnlineWorms.Server
|
|||||||
Name = "Boredom Time",
|
Name = "Boredom Time",
|
||||||
EndPoint = new IPEndPoint(IPAddress.Loopback, 3),
|
EndPoint = new IPEndPoint(IPAddress.Loopback, 3),
|
||||||
Type = ChannelType.Normal,
|
Type = ChannelType.Normal,
|
||||||
UserLoad = 3
|
Load = ChannelLoad.Medium
|
||||||
},
|
},
|
||||||
new ChannelInfo
|
new ChannelInfo
|
||||||
{
|
{
|
||||||
@ -96,7 +96,7 @@ namespace Syroot.Worms.OnlineWorms.Server
|
|||||||
Type = ChannelType.Roping,
|
Type = ChannelType.Roping,
|
||||||
Color = Color.Orange,
|
Color = Color.Orange,
|
||||||
Coins = 2,
|
Coins = 2,
|
||||||
UserLoad = 6
|
Load = ChannelLoad.Closed
|
||||||
},
|
},
|
||||||
new ChannelInfo
|
new ChannelInfo
|
||||||
{
|
{
|
||||||
@ -105,7 +105,7 @@ namespace Syroot.Worms.OnlineWorms.Server
|
|||||||
Type = ChannelType.Roping,
|
Type = ChannelType.Roping,
|
||||||
Color = Color.Orange,
|
Color = Color.Orange,
|
||||||
Coins = 1,
|
Coins = 1,
|
||||||
UserLoad = 5
|
Load = ChannelLoad.Full
|
||||||
},
|
},
|
||||||
new ChannelInfo
|
new ChannelInfo
|
||||||
{
|
{
|
||||||
@ -126,8 +126,12 @@ namespace Syroot.Worms.OnlineWorms.Server
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void HandleChannelConnect(ChannelConnectQuery packet)
|
||||||
|
{
|
||||||
|
}
|
||||||
|
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
public void HandleRaw(RawQuery packet) { }
|
public void HandleRaw(RawPacket packet) { }
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
// ---- METHODS (PROTECTED) ------------------------------------------------------------------------------------
|
// ---- METHODS (PROTECTED) ------------------------------------------------------------------------------------
|
||||||
|
@ -16,6 +16,9 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
// ---- CONSTANTS ----------------------------------------------------------------------------------------------
|
// ---- CONSTANTS ----------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
private const int _maxDataSize = 2048;
|
private const int _maxDataSize = 2048;
|
||||||
|
private const ushort _channelPacketStartTag = 0xFFFE;
|
||||||
|
private const byte _channelPacketStartTag2 = 1;
|
||||||
|
private const ushort _channelPacketEndTag = 0xFEFF;
|
||||||
|
|
||||||
// ---- FIELDS -------------------------------------------------------------------------------------------------
|
// ---- FIELDS -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -123,19 +126,39 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
private Packet ReceivePacket()
|
private Packet ReceivePacket()
|
||||||
{
|
{
|
||||||
// Receive the raw packet data.
|
// Receive the raw packet data.
|
||||||
ushort id;
|
PacketType type;
|
||||||
|
int id;
|
||||||
ushort dataSize;
|
ushort dataSize;
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
id = _receiveStream.ReadUInt16();
|
// Handle both server and channel specific packet formats.
|
||||||
dataSize = _receiveStream.ReadUInt16();
|
ushort tag = _receiveStream.ReadUInt16();
|
||||||
_receiveStream.ReadAll(_receiveBuffer, 0, dataSize);
|
if (tag == _channelPacketStartTag)
|
||||||
|
{
|
||||||
|
type = PacketType.Channel;
|
||||||
|
if (_receiveStream.Read1Byte() != 1)
|
||||||
|
throw new IOException("Invalid channel packet start tag.");
|
||||||
|
dataSize = _receiveStream.ReadUInt16();
|
||||||
|
id = _receiveStream.Read1Byte();
|
||||||
|
_receiveStream.ReadAll(_receiveBuffer, 0, dataSize - sizeof(byte));
|
||||||
|
_ = _receiveStream.Read1Byte(); // ?
|
||||||
|
ushort endTag = _receiveStream.ReadUInt16();
|
||||||
|
if (endTag != _channelPacketEndTag)
|
||||||
|
throw new IOException("Invalid channel packet end tag.");
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
type = PacketType.Server;
|
||||||
|
id = tag;
|
||||||
|
dataSize = _receiveStream.ReadUInt16();
|
||||||
|
_receiveStream.ReadAll(_receiveBuffer, 0, dataSize);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
catch (IOException) { return null; } // The underlying socket closed.
|
catch (IOException) { return null; } // The underlying socket closed.
|
||||||
catch (ObjectDisposedException) { return null; } // The underlying stream closed.
|
catch (ObjectDisposedException) { return null; } // The underlying stream closed.
|
||||||
|
|
||||||
// Deserialize and return the packet.
|
// Deserialize and return the packet.
|
||||||
Packet packet = PacketFactory.Create(id);
|
Packet packet = PacketFactory.Create(type, id);
|
||||||
using (PacketStream readStream = new PacketStream(new MemoryStream(_receiveBuffer, 0, dataSize, false)))
|
using (PacketStream readStream = new PacketStream(new MemoryStream(_receiveBuffer, 0, dataSize, false)))
|
||||||
packet.Deserialize(readStream);
|
packet.Deserialize(readStream);
|
||||||
return packet;
|
return packet;
|
||||||
@ -153,9 +176,25 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
// Send the data and return success.
|
// Send the data and return success.
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
_receiveStream.WriteUInt16(PacketFactory.GetID(packet));
|
PacketAttribute attribute = PacketFactory.GetAttribute(packet);
|
||||||
_receiveStream.WriteUInt16(dataSize);
|
switch (attribute.PacketType)
|
||||||
_receiveStream.Write(_sendDataBuffer, 0, dataSize);
|
{
|
||||||
|
case PacketType.Channel:
|
||||||
|
_receiveStream.WriteUInt16(_channelPacketStartTag);
|
||||||
|
_receiveStream.WriteByte(1);
|
||||||
|
_receiveStream.WriteUInt16(dataSize);
|
||||||
|
_receiveStream.Write(_sendDataBuffer, 0, dataSize);
|
||||||
|
_receiveStream.WriteByte(0); // ?
|
||||||
|
_receiveStream.Write(_channelPacketEndTag);
|
||||||
|
break;
|
||||||
|
case PacketType.Server:
|
||||||
|
_receiveStream.WriteUInt16((ushort)attribute.PacketID);
|
||||||
|
_receiveStream.WriteUInt16(dataSize);
|
||||||
|
_receiveStream.Write(_sendDataBuffer, 0, dataSize);
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
throw new InvalidOperationException("Cannot send unknown packet type.");
|
||||||
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
catch (IOException) { return false; } // A network error appeared, and communication should end.
|
catch (IOException) { return false; } // A network error appeared, and communication should end.
|
||||||
|
@ -15,9 +15,10 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
/// packet it represents.
|
/// packet it represents.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="id">The ID of the packet which the decorated class represents.</param>
|
/// <param name="id">The ID of the packet which the decorated class represents.</param>
|
||||||
public PacketAttribute(ushort id)
|
public PacketAttribute(PacketType type, int id)
|
||||||
{
|
{
|
||||||
ID = id;
|
PacketType = type;
|
||||||
|
PacketID = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||||
@ -25,6 +26,14 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the ID of the packet the decorated class represents.
|
/// Gets the ID of the packet the decorated class represents.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public ushort ID { get; }
|
public int PacketID { get; }
|
||||||
|
|
||||||
|
public PacketType PacketType { get; }
|
||||||
|
}
|
||||||
|
|
||||||
|
internal enum PacketType
|
||||||
|
{
|
||||||
|
Server,
|
||||||
|
Channel
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
{
|
{
|
||||||
// ---- FIELDS -------------------------------------------------------------------------------------------------
|
// ---- FIELDS -------------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
private static readonly Dictionary<ushort, Type> _packetTypes = new Dictionary<ushort, Type>();
|
private static readonly Dictionary<PacketAttribute, Type> _packetMetas = new Dictionary<PacketAttribute, Type>();
|
||||||
|
|
||||||
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
||||||
|
|
||||||
@ -21,11 +21,14 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
// Cache the ID-to-packet-class map.
|
// Cache the ID-to-packet-class map.
|
||||||
foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
|
foreach (Type type in Assembly.GetExecutingAssembly().GetTypes())
|
||||||
{
|
{
|
||||||
foreach (PacketAttribute packetAttribute in type.GetCustomAttributes<PacketAttribute>())
|
foreach (PacketAttribute attrib in type.GetCustomAttributes<PacketAttribute>())
|
||||||
{
|
{
|
||||||
if (_packetTypes.ContainsKey(packetAttribute.ID))
|
if (_packetMetas.ContainsKey(attrib))
|
||||||
throw new InvalidOperationException($"Packet {packetAttribute.ID} mapped to multiple classes.");
|
{
|
||||||
_packetTypes.Add(packetAttribute.ID, type);
|
throw new InvalidOperationException(
|
||||||
|
$"{attrib.PacketType} packet with ID {attrib.PacketID} mapped to multiple classes.");
|
||||||
|
}
|
||||||
|
_packetMetas.Add(attrib, type);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -38,30 +41,33 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
/// <param name="id">The ID of the packet class to instantiate.</param>
|
/// <param name="id">The ID of the packet class to instantiate.</param>
|
||||||
/// <returns>The created <see cref="Packet"/> instance.</returns>
|
/// <returns>The created <see cref="Packet"/> instance.</returns>
|
||||||
/// <exception cref="KeyNotFoundException">No class was mapped to the given packet ID.</exception>
|
/// <exception cref="KeyNotFoundException">No class was mapped to the given packet ID.</exception>
|
||||||
internal static Packet Create(ushort id)
|
internal static Packet Create(PacketType type, int id)
|
||||||
{
|
{
|
||||||
|
foreach (KeyValuePair<PacketAttribute, Type> packetMeta in _packetMetas)
|
||||||
|
{
|
||||||
|
if (packetMeta.Key.PacketType == type && packetMeta.Key.PacketID == id)
|
||||||
|
return (Packet)Activator.CreateInstance(packetMeta.Value, true);
|
||||||
|
}
|
||||||
|
// No packet metadata matching.
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
return _packetTypes.TryGetValue(id, out Type type)
|
return new RawPacket(type, id);
|
||||||
? (Packet)Activator.CreateInstance(type, true)
|
|
||||||
: new RawQuery(id);
|
|
||||||
#else
|
|
||||||
return (Packet)Activator.CreateInstance(_packetTypes[id], true);
|
|
||||||
#endif
|
#endif
|
||||||
|
throw new ArgumentException($"{type} packet with ID {id} could not be created.");
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets the ID for the class of the given <paramref name="packet"/>.
|
/// Gets the <see cref="PacketAttribute"/> metadata for the class of the given <paramref name="packet"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// <param name="packet">The packet, whose class ID will be returned.</param>
|
/// <param name="packet">The <see cref="Packet"/> whose metadata will be returned.</param>
|
||||||
/// <returns>The ID of the <see cref="Packet"/> class.</returns>
|
/// <returns>The metadata of the packet class.</returns>
|
||||||
internal static ushort GetID(Packet packet)
|
internal static PacketAttribute GetAttribute(Packet packet)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
if (packet is RawQuery rawPacket)
|
if (packet is RawPacket rawPacket)
|
||||||
return rawPacket.ID;
|
return new PacketAttribute(rawPacket.Type, rawPacket.ID);
|
||||||
else
|
else
|
||||||
#endif
|
#endif
|
||||||
return _packetTypes.Where(x => x.Value == packet.GetType()).First().Key;
|
return _packetMetas.Where(x => x.Value == packet.GetType()).First().Key;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -91,6 +91,15 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal string ReadString(int bufferSize)
|
||||||
|
{
|
||||||
|
// Ensure to not try to decode any bytes after the 0 termination.
|
||||||
|
byte[] bytes = _baseStream.ReadBytes(bufferSize);
|
||||||
|
int length = bufferSize;
|
||||||
|
while (bytes[--length] == 0 && length > 0) { }
|
||||||
|
return _win949Encoding.GetString(bytes, 0, length + 1);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reads a 2-byte length-prefixed, Windows-949 enoded string.
|
/// Reads a 2-byte length-prefixed, Windows-949 enoded string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
@ -121,6 +130,13 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
_baseStream.WriteByte(0);
|
_baseStream.WriteByte(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal void WriteString(string value, int bufferSize)
|
||||||
|
{
|
||||||
|
byte[] bytes = new byte[bufferSize];
|
||||||
|
_win949Encoding.GetBytes(value, 0, value.Length, bytes, 0);
|
||||||
|
_baseStream.WriteBytes(bytes);
|
||||||
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Writes a 2-byte length-prefixed, Windows-949 encoded string.
|
/// Writes a 2-byte length-prefixed, Windows-949 encoded string.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
@ -0,0 +1,59 @@
|
|||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Net;
|
||||||
|
using Syroot.BinaryData;
|
||||||
|
|
||||||
|
namespace Syroot.Worms.OnlineWorms.Server.Net
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Represents the client request for a <see cref="?"/>.
|
||||||
|
/// </summary>
|
||||||
|
[Packet(PacketType.Channel, 0x10)]
|
||||||
|
internal class ChannelConnectQuery : Packet
|
||||||
|
{
|
||||||
|
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
public IList<ChannelConnectPlayer> Players { get; set; }
|
||||||
|
|
||||||
|
public IPAddress ClientIP { get; set; }
|
||||||
|
|
||||||
|
public ushort ClientVersion { get; set; }
|
||||||
|
|
||||||
|
public ushort UnknownA { get; set; } // Always 1?
|
||||||
|
|
||||||
|
// ---- METHODS (INTERNAL) -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
internal override void Deserialize(PacketStream stream)
|
||||||
|
{
|
||||||
|
Players = new List<ChannelConnectPlayer>
|
||||||
|
{
|
||||||
|
new ChannelConnectPlayer
|
||||||
|
{
|
||||||
|
ID = stream.ReadString(12),
|
||||||
|
Password = stream.ReadString(12)
|
||||||
|
}
|
||||||
|
};
|
||||||
|
ClientIP = IPAddress.Parse(stream.ReadString(15));
|
||||||
|
ClientVersion = stream.ReadUInt16();
|
||||||
|
UnknownA = stream.ReadUInt16();
|
||||||
|
|
||||||
|
ushort additionalPlayers = stream.ReadUInt16();
|
||||||
|
for (int i = 0; i < additionalPlayers; i++)
|
||||||
|
{
|
||||||
|
Players.Add(new ChannelConnectPlayer
|
||||||
|
{
|
||||||
|
ID = stream.ReadString(12),
|
||||||
|
Password = stream.ReadString(12)
|
||||||
|
});
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
internal override void Serialize(PacketStream stream) => throw new NotImplementedException();
|
||||||
|
}
|
||||||
|
|
||||||
|
internal class ChannelConnectPlayer
|
||||||
|
{
|
||||||
|
public string ID { get; set; } // Max. 12 characters.
|
||||||
|
public string Password { get; set; } // Max. 12 characters.
|
||||||
|
}
|
||||||
|
}
|
@ -7,7 +7,7 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the client request for a <see cref="ChannelEnterReply"/>.
|
/// Represents the client request for a <see cref="ChannelEnterReply"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Packet(0x8034)]
|
[Packet(PacketType.Server, 0x8034)]
|
||||||
internal class ChannelEnterQuery : Packet
|
internal class ChannelEnterQuery : Packet
|
||||||
{
|
{
|
||||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||||
|
@ -7,7 +7,7 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the server response to a <see cref="ChannelEnterQuery"/>.
|
/// Represents the server response to a <see cref="ChannelEnterQuery"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Packet(0x8035)]
|
[Packet(PacketType.Server, 0x8035)]
|
||||||
internal class ChannelEnterReply : Packet
|
internal class ChannelEnterReply : Packet
|
||||||
{
|
{
|
||||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||||
|
@ -9,7 +9,7 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents an additional server response to a <see cref="LoginQuery"/>, providing available server channels.
|
/// Represents an additional server response to a <see cref="LoginQuery"/>, providing available server channels.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Packet(0x80C9)]
|
[Packet(PacketType.Server, 0x80C9)]
|
||||||
internal class ChannelInfosReply : Packet
|
internal class ChannelInfosReply : Packet
|
||||||
{
|
{
|
||||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||||
@ -35,7 +35,7 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
|
|
||||||
stream.WriteBytes(channel.EndPoint.Address.GetAddressBytes());
|
stream.WriteBytes(channel.EndPoint.Address.GetAddressBytes());
|
||||||
stream.WriteUInt16((ushort)channel.EndPoint.Port);
|
stream.WriteUInt16((ushort)channel.EndPoint.Port);
|
||||||
stream.WriteByte(channel.UserLoad);
|
stream.WriteEnum(channel.Load);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -68,10 +68,9 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
internal Color Color { get; set; } = Color.White;
|
internal Color Color { get; set; } = Color.White;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets an indicator of the number of players in this channel. 0 hides the channel, and 6 represents a
|
/// Gets or sets an indicator or state visualizing the number of players in this channel.
|
||||||
/// full channel.
|
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal byte UserLoad { get; set; } = 1;
|
internal ChannelLoad Load { get; set; } = ChannelLoad.Lowest;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal enum ChannelType : byte
|
internal enum ChannelType : byte
|
||||||
@ -80,4 +79,16 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
Roping = 1,
|
Roping = 1,
|
||||||
Special = 2
|
Special = 2
|
||||||
}
|
}
|
||||||
|
|
||||||
|
internal enum ChannelLoad : byte
|
||||||
|
{
|
||||||
|
Hidden,
|
||||||
|
Lowest,
|
||||||
|
Low,
|
||||||
|
Medium,
|
||||||
|
High,
|
||||||
|
Highest,
|
||||||
|
Full,
|
||||||
|
Closed = 99
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,7 +5,7 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the client request for a <see cref="ConnectReply"/>.
|
/// Represents the client request for a <see cref="ConnectReply"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Packet(0x800E)]
|
[Packet(PacketType.Server, 0x800E)]
|
||||||
internal class ConnectQuery : Packet
|
internal class ConnectQuery : Packet
|
||||||
{
|
{
|
||||||
// ---- METHODS (INTERNAL) -------------------------------------------------------------------------------------
|
// ---- METHODS (INTERNAL) -------------------------------------------------------------------------------------
|
||||||
|
@ -6,7 +6,7 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the server response to a <see cref="ConnectQuery"/>.
|
/// Represents the server response to a <see cref="ConnectQuery"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Packet(0x800F)]
|
[Packet(PacketType.Server, 0x800F)]
|
||||||
internal class ConnectReply : Packet
|
internal class ConnectReply : Packet
|
||||||
{
|
{
|
||||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||||
|
@ -7,7 +7,7 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the client request for a <see cref="LoginReply"/>.
|
/// Represents the client request for a <see cref="LoginReply"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Packet(0x8000)]
|
[Packet(PacketType.Server, 0x8000)]
|
||||||
internal class LoginQuery : Packet
|
internal class LoginQuery : Packet
|
||||||
{
|
{
|
||||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||||
|
@ -6,7 +6,7 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents the server response to a <see cref="LoginQuery"/>.
|
/// Represents the server response to a <see cref="LoginQuery"/>.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Packet(0x8001)]
|
[Packet(PacketType.Server, 0x8001)]
|
||||||
internal class LoginReply : Packet
|
internal class LoginReply : Packet
|
||||||
{
|
{
|
||||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||||
|
@ -1,36 +1,33 @@
|
|||||||
#if DEBUG
|
#if DEBUG
|
||||||
|
using Syroot.BinaryData;
|
||||||
|
|
||||||
namespace Syroot.Worms.OnlineWorms.Server.Net
|
namespace Syroot.Worms.OnlineWorms.Server.Net
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Represents a special fallback packet which simply stores any ID and the raw client packet data.
|
/// Represents a special fallback packet which simply stores any ID and the raw packet data.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal class RawQuery : Packet
|
internal class RawPacket : Packet
|
||||||
{
|
{
|
||||||
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
||||||
|
|
||||||
internal RawQuery(ushort id)
|
internal RawPacket(PacketType type, int id)
|
||||||
{
|
{
|
||||||
|
Type = type;
|
||||||
ID = id;
|
ID = id;
|
||||||
}
|
}
|
||||||
|
|
||||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||||
|
|
||||||
internal ushort ID { get; }
|
internal PacketType Type { get; }
|
||||||
|
|
||||||
|
internal int ID { get; }
|
||||||
|
|
||||||
internal byte[] Data { get; set; }
|
internal byte[] Data { get; set; }
|
||||||
|
|
||||||
// ---- METHODS (INTERNAL) -------------------------------------------------------------------------------------
|
// ---- METHODS (INTERNAL) -------------------------------------------------------------------------------------
|
||||||
|
|
||||||
internal override void Deserialize(PacketStream stream)
|
internal override void Deserialize(PacketStream stream) => Data = stream.ReadBytes((int)stream.Length);
|
||||||
{
|
internal override void Serialize(PacketStream stream) => stream.WriteBytes(Data);
|
||||||
Data = new byte[stream.Length];
|
|
||||||
stream.Read(Data, 0, Data.Length);
|
|
||||||
}
|
|
||||||
|
|
||||||
internal override void Serialize(PacketStream stream)
|
|
||||||
{
|
|
||||||
stream.Write(Data, 0, Data.Length);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
@ -6,7 +6,7 @@ namespace Syroot.Worms.OnlineWorms.Server.Net
|
|||||||
/// Represents an additional server response to a <see cref="LoginQuery"/>, providing informational server
|
/// Represents an additional server response to a <see cref="LoginQuery"/>, providing informational server
|
||||||
/// screen text.
|
/// screen text.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[Packet(0x8033)]
|
[Packet(PacketType.Server, 0x8033)]
|
||||||
internal class ServerInfoReply : Packet
|
internal class ServerInfoReply : Packet
|
||||||
{
|
{
|
||||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||||
|
Loading…
x
Reference in New Issue
Block a user