Skip to content

Commit

Permalink
add SendUnconnectedMessage with ReadOnlySpan argument
Browse files Browse the repository at this point in the history
  • Loading branch information
RevenantX committed Apr 18, 2024
1 parent 5c90a50 commit d800531
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions LiteNetLib/NetManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1268,6 +1268,21 @@ public void SendToAll(ReadOnlySpan<byte> data, byte channelNumber, DeliveryMetho
_peersLock.ExitReadLock();
}
}

/// <summary>
/// Send message without connection
/// </summary>
/// <param name="message">Raw data</param>
/// <param name="remoteEndPoint">Packet destination</param>
/// <returns>Operation result</returns>
public bool SendUnconnectedMessage(ReadOnlySpan<byte> message, IPEndPoint remoteEndPoint)
{
int headerSize = NetPacket.GetHeaderSize(PacketProperty.UnconnectedMessage);
var packet = PoolGetPacket(message.Length + headerSize);
packet.Property = PacketProperty.UnconnectedMessage;
message.CopyTo(new Span<byte>(packet.RawData, headerSize, message.Length));
return SendRawAndRecycle(packet, remoteEndPoint) > 0;
}
#endif

/// <summary>
Expand Down

0 comments on commit d800531

Please sign in to comment.