Skip to content

Instantly share code, notes, and snippets.

@ThuCommix
Created March 7, 2015 22:39
Show Gist options
  • Save ThuCommix/ea41e0ebb7e67ce5e0ce to your computer and use it in GitHub Desktop.
Save ThuCommix/ea41e0ebb7e67ce5e0ce to your computer and use it in GitHub Desktop.
/// <summary>
/// Sends the data.
/// </summary>
/// <param name="buffer">The Buffer.</param>
/// <param name="count">The Count.</param>
/// <param name="member">The SessionMember.</param>
public void Send(byte[] buffer, int count, SessionMember member)
{
var data = new byte[10 + count];
var msg = BitConverter.GetBytes((short) SystemMessage.UserDatagram);
var ip = member.IpEndPoint.Address.GetAddressBytes();
var port = BitConverter.GetBytes(member.IpEndPoint.Port);
Array.Copy(msg, 0, data, 0, 2);
Array.Copy(ip, 0, data, 2, 4);
Array.Copy(port, 0, data, 6, 4);
Array.Copy(buffer, 0, data, 10, count);
_udpService.BeginSend(data, count + 10, AsyncSentCallback, new AsyncSentState(count + 10));
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment