AddPlayerMessage inherits from BytesMessage

This commit is contained in:
vis2k 2019-01-15 15:32:42 +01:00
parent 3fce3ae675
commit d94b1a2d89
3 changed files with 4 additions and 17 deletions

View File

@ -106,7 +106,7 @@ public static bool AddPlayer(NetworkConnection readyConn, MessageBase extraMessa
{ {
NetworkWriter writer = new NetworkWriter(); NetworkWriter writer = new NetworkWriter();
extraMessage.Serialize(writer); extraMessage.Serialize(writer);
msg.msgData = writer.ToArray(); msg.value = writer.ToArray();
} }
s_ReadyConnection.Send((short)MsgType.AddPlayer, msg); s_ReadyConnection.Send((short)MsgType.AddPlayer, msg);
return true; return true;

View File

@ -145,20 +145,7 @@ public class ReadyMessage : EmptyMessage {}
public class NotReadyMessage : EmptyMessage {} public class NotReadyMessage : EmptyMessage {}
public class AddPlayerMessage : MessageBase public class AddPlayerMessage : BytesMessage {}
{
public byte[] msgData;
public override void Deserialize(NetworkReader reader)
{
msgData = reader.ReadBytesAndSize();
}
public override void Serialize(NetworkWriter writer)
{
writer.WriteBytesAndSize(msgData);
}
}
public class RemovePlayerMessage : EmptyMessage public class RemovePlayerMessage : EmptyMessage
{ {

View File

@ -510,9 +510,9 @@ internal void OnServerAddPlayerMessageInternal(NetworkMessage netMsg)
AddPlayerMessage msg = netMsg.ReadMessage<AddPlayerMessage>(); AddPlayerMessage msg = netMsg.ReadMessage<AddPlayerMessage>();
if (msg.msgData != null && msg.msgData.Length > 0) if (msg.value != null && msg.value.Length > 0)
{ {
NetworkReader reader = new NetworkReader(msg.msgData); NetworkReader reader = new NetworkReader(msg.value);
OnServerAddPlayer(netMsg.conn, reader); OnServerAddPlayer(netMsg.conn, reader);
} }
else else