ErrorMessage reuses ByteMessage

This commit is contained in:
vis2k 2019-01-15 15:39:19 +01:00
parent b2fa2eebed
commit a5e3ec35c1
4 changed files with 5 additions and 18 deletions

View File

@ -150,20 +150,7 @@ public override void Serialize(NetworkWriter writer)
// ---------- Public System Messages -------------------
public class ErrorMessage : MessageBase
{
public byte errorCode; // byte instead of int because NetworkServer uses byte anyway. saves bandwidth.
public override void Deserialize(NetworkReader reader)
{
errorCode = reader.ReadByte();
}
public override void Serialize(NetworkWriter writer)
{
writer.Write(errorCode);
}
}
public class ErrorMessage : ByteMessage {}
public class ReadyMessage : EmptyMessage {}

View File

@ -244,7 +244,7 @@ void GenerateError(byte error)
if (m_MessageHandlers.TryGetValue((short)MsgType.Error, out msgDelegate))
{
ErrorMessage msg = new ErrorMessage();
msg.errorCode = error;
msg.value = error;
// write the message to a local buffer
NetworkWriter writer = new NetworkWriter();

View File

@ -537,7 +537,7 @@ internal void OnServerErrorInternal(NetworkMessage netMsg)
if (LogFilter.Debug) { Debug.Log("NetworkManager:OnServerErrorInternal"); }
ErrorMessage msg = netMsg.ReadMessage<ErrorMessage>();
OnServerError(netMsg.conn, msg.errorCode);
OnServerError(netMsg.conn, msg.value);
}
// ----------------------------- Client Internal Message Handlers --------------------------------
@ -586,7 +586,7 @@ internal void OnClientErrorInternal(NetworkMessage netMsg)
if (LogFilter.Debug) { Debug.Log("NetworkManager:OnClientErrorInternal"); }
ErrorMessage msg = netMsg.ReadMessage<ErrorMessage>();
OnClientError(netMsg.conn, msg.errorCode);
OnClientError(netMsg.conn, msg.value);
}
internal void OnClientSceneInternal(NetworkMessage netMsg)

View File

@ -449,7 +449,7 @@ static void GenerateError(NetworkConnection conn, byte error)
if (handlers.ContainsKey((short)MsgType.Error))
{
ErrorMessage msg = new ErrorMessage();
msg.errorCode = error;
msg.value = error;
// write the message to a local buffer
NetworkWriter writer = new NetworkWriter();