예제 #1
0
        public static void Send(this UdpConnection connection, MessageWriter msg, Action ackCallback)
        {
            if (msg.SendOption != SendOption.Reliable)
            {
                throw new InvalidOperationException("Message SendOption has to be Reliable.");
            }

            var buffer = new byte[msg.Length];

            Buffer.BlockCopy(msg.Buffer, 0, buffer, 0, msg.Length);

            connection.ResetKeepAliveTimer();

            connection.AttachReliableID(buffer, 1, ackCallback);
            connection.WriteBytesToConnection(buffer, buffer.Length);
            connection.Statistics.LogReliableSend(buffer.Length - 3, buffer.Length);
        }