using FishNet.Managing.Scened;
using FishNet.Managing.Server;
using FishNet.Object.Helping;
using FishNet.Transporting;
using UnityEngine;
namespace FishNet.Serializing.Helping
{
internal static class Broadcasts
{
///
/// Writes a broadcast to writer.
///
///
///
///
///
///
internal static PooledWriter WriteBroadcast(PooledWriter writer, T message, Channel channel)
{
writer.WritePacketId(PacketId.Broadcast);
writer.WriteUInt16(typeof(T).FullName.GetStableHash16()); //muchlater codegen this to pass in hash. use technique similar to rpcs to limit byte/shorts.
//Write data to a new writer.
PooledWriter dataWriter = WriterPool.GetWriter();
dataWriter.Write(message);
//Write length of data.
writer.WriteLength(dataWriter.Length);
//Write data.
writer.WriteArraySegment(dataWriter.GetArraySegment());
dataWriter.Dispose();
return writer;
}
}
}