示例#1
0
        /// <summary>
        ///     Send a custom PsnPacketChunk
        /// </summary>
        /// <exception cref="ArgumentNullException"></exception>
        /// <exception cref="ArgumentException"></exception>
        public void SendCustomPacket([NotNull] PsnPacketChunk chunk)
        {
            if (chunk == null)
            {
                throw new ArgumentNullException(nameof(chunk));
            }

            var bytes = chunk.ToByteArray();

            if (bytes.Length > MaxPacketLength)
            {
                throw new ArgumentException(
                          $"Serialized chunk length ({bytes.Length}) is longer than maximum PosiStageNet packet length ({MaxPacketLength})");
            }

            _udpService.SendAsync(bytes, _targetEndPoint).Wait();
        }
示例#2
0
 internal InvalidPacketsReceivedEventArgs(PsnPacketChunk packet, bool wasProcessed, string message)
 {
     Packets      = new[] { packet };
     WasProcessed = wasProcessed;
     Message      = message;
 }