mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
ErrorMessage reuses ByteMessage
This commit is contained in:
parent
b2fa2eebed
commit
a5e3ec35c1
@ -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 {}
|
||||
|
||||
|
@ -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();
|
||||
|
@ -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)
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user