mirror of
https://github.com/MirrorNetworking/Mirror.git
synced 2024-11-18 02:50:32 +00:00
SendWriter functions removed to avoid redundancy with SendBytes. Simply call SendBytes(writer.ToArray()) instead.
This commit is contained in:
parent
2e9dc82e0e
commit
fc4080535b
@ -32,12 +32,6 @@ public override bool SendBytes(byte[] bytes, int channelId)
|
||||
m_LocalClient.InvokeBytesOnClient(bytes, channelId);
|
||||
return true;
|
||||
}
|
||||
|
||||
public override bool SendWriter(NetworkWriter writer, int channelId)
|
||||
{
|
||||
m_LocalClient.InvokeBytesOnClient(writer.ToArray(), channelId);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// a localClient's connection TO a server.
|
||||
@ -67,12 +61,6 @@ public override bool SendBytes(byte[] bytes, int channelId)
|
||||
}
|
||||
return NetworkServer.InvokeBytes(this, bytes, channelId);
|
||||
}
|
||||
|
||||
public override bool SendWriter(NetworkWriter writer, int channelId)
|
||||
{
|
||||
// write relevant data, which is until .Position
|
||||
return NetworkServer.InvokeBytes(this, writer.ToArray(), channelId);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif //ENABLE_UNET
|
||||
|
@ -68,7 +68,7 @@ protected void SendCommandInternal(NetworkWriter writer, int channelId, string c
|
||||
}
|
||||
|
||||
writer.FinishMessage();
|
||||
ClientScene.readyConnection.SendWriter(writer, channelId);
|
||||
ClientScene.readyConnection.SendBytes(writer.ToArray(), channelId);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.NetworkDetailStats.IncrementStat(
|
||||
@ -96,7 +96,7 @@ protected void SendRPCInternal(NetworkWriter writer, int channelId, string rpcNa
|
||||
}
|
||||
|
||||
writer.FinishMessage();
|
||||
NetworkServer.SendWriterToReady(gameObject, writer, channelId);
|
||||
NetworkServer.SendBytesToReady(gameObject, writer.ToArray(), channelId);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.NetworkDetailStats.IncrementStat(
|
||||
@ -117,7 +117,7 @@ protected void SendTargetRPCInternal(NetworkConnection conn, NetworkWriter write
|
||||
|
||||
writer.FinishMessage();
|
||||
|
||||
conn.SendWriter(writer, channelId);
|
||||
conn.SendBytes(writer.ToArray(), channelId);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.NetworkDetailStats.IncrementStat(
|
||||
@ -144,7 +144,7 @@ protected void SendEventInternal(NetworkWriter writer, int channelId, string eve
|
||||
}
|
||||
|
||||
writer.FinishMessage();
|
||||
NetworkServer.SendWriterToReady(gameObject, writer, channelId);
|
||||
NetworkServer.SendBytesToReady(gameObject, writer.ToArray(), channelId);
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.NetworkDetailStats.IncrementStat(
|
||||
|
@ -302,21 +302,6 @@ public virtual void Disconnect()
|
||||
}
|
||||
}
|
||||
|
||||
public bool SendWriter(NetworkWriter writer, int channelId)
|
||||
{
|
||||
if (m_Connection != null)
|
||||
{
|
||||
if (m_AsyncConnect != ConnectState.Connected)
|
||||
{
|
||||
if (LogFilter.logError) { Debug.LogError("NetworkClient SendWriter when not connected to a server"); }
|
||||
return false;
|
||||
}
|
||||
return m_Connection.SendWriter(writer, channelId);
|
||||
}
|
||||
if (LogFilter.logError) { Debug.LogError("NetworkClient SendWriter with no connection"); }
|
||||
return false;
|
||||
}
|
||||
|
||||
public bool SendBytes(byte[] data, int channelId)
|
||||
{
|
||||
if (m_Connection != null)
|
||||
|
@ -183,7 +183,7 @@ public virtual bool SendByChannel(short msgType, MessageBase msg, int channelId)
|
||||
writer.StartMessage(msgType);
|
||||
msg.Serialize(writer);
|
||||
writer.FinishMessage();
|
||||
return SendWriter(writer, channelId);
|
||||
return SendBytes(writer.ToArray(), channelId);
|
||||
}
|
||||
public virtual bool Send(short msgType, MessageBase msg) { return SendByChannel(msgType, msg, Channels.DefaultReliable); }
|
||||
public virtual bool SendUnreliable(short msgType, MessageBase msg) { return SendByChannel(msgType, msg, Channels.DefaultUnreliable); }
|
||||
@ -217,12 +217,6 @@ public virtual bool SendBytes(byte[] bytes, int channelId)
|
||||
return TransportSend(bytes, channelId, out error);
|
||||
}
|
||||
|
||||
public virtual bool SendWriter(NetworkWriter writer, int channelId)
|
||||
{
|
||||
// write relevant data, which is until .Position
|
||||
return SendBytes(writer.ToArray(), channelId);
|
||||
}
|
||||
|
||||
void LogSend(byte[] bytes)
|
||||
{
|
||||
NetworkReader reader = new NetworkReader(bytes);
|
||||
|
@ -732,7 +732,7 @@ internal void UNetUpdate()
|
||||
}
|
||||
|
||||
writer.FinishMessage();
|
||||
NetworkServer.SendWriterToReady(gameObject, writer, channelId);
|
||||
NetworkServer.SendBytesToReady(gameObject, writer.ToArray(), channelId);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -283,18 +283,6 @@ static bool SendToObservers(GameObject contextObj, short msgType, MessageBase ms
|
||||
return false;
|
||||
}
|
||||
|
||||
// End users should not send random bytes
|
||||
// because the other side might interpret them as messages
|
||||
static internal void SendWriterToReady(GameObject contextObj, NetworkWriter writer, int channelId)
|
||||
{
|
||||
if (writer.Position > UInt16.MaxValue)
|
||||
{
|
||||
throw new UnityException("NetworkWriter used buffer is too big!");
|
||||
}
|
||||
// send relevant data, which is until .Position
|
||||
SendBytesToReady(contextObj, writer.ToArray(), channelId);
|
||||
}
|
||||
|
||||
// End users should not send random bytes
|
||||
// because the other side might interpret them as messages
|
||||
static internal void SendBytesToReady(GameObject contextObj, byte[] buffer, int channelId)
|
||||
|
@ -400,7 +400,7 @@ void SendTransform()
|
||||
UnityEditor.NetworkDetailStats.NetworkDirection.Outgoing,
|
||||
(short)MsgType.LocalChildTransform, "16:LocalChildTransform", 1);
|
||||
#endif
|
||||
ClientScene.readyConnection.SendWriter(writer, GetNetworkChannel());
|
||||
ClientScene.readyConnection.SendBytes(writer.ToArray(), GetNetworkChannel());
|
||||
}
|
||||
|
||||
static internal void HandleChildTransform(NetworkMessage netMsg)
|
||||
|
@ -1238,7 +1238,7 @@ void SendTransform()
|
||||
UnityEditor.NetworkDetailStats.NetworkDirection.Outgoing,
|
||||
(short)MsgType.LocalPlayerTransform, "6:LocalPlayerTransform", 1);
|
||||
#endif
|
||||
ClientScene.readyConnection.SendWriter(writer, GetNetworkChannel());
|
||||
ClientScene.readyConnection.SendBytes(writer.ToArray(), GetNetworkChannel());
|
||||
}
|
||||
|
||||
static public void HandleTransform(NetworkMessage netMsg)
|
||||
|
@ -258,7 +258,7 @@ void SendMsg(Operation op, int itemIndex, T item)
|
||||
SerializeItem(writer, item);
|
||||
writer.FinishMessage();
|
||||
|
||||
NetworkServer.SendWriterToReady(uv.gameObject, writer, m_Behaviour.GetNetworkChannel());
|
||||
NetworkServer.SendBytesToReady(uv.gameObject, writer.ToArray(), m_Behaviour.GetNetworkChannel());
|
||||
|
||||
#if UNITY_EDITOR
|
||||
UnityEditor.NetworkDetailStats.IncrementStat(
|
||||
|
Loading…
Reference in New Issue
Block a user