示例#1
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="SntpMessageEventArgs" /> class.
        /// </summary>
        /// <param name="channel">Socket channel request is recived on.</param>
        /// <param name="data">Raw data received from socket.</param>
        public SntpMessageEventArgs(SocketChannel channel, SocketBuffer data)
        {
            if (channel == null)
            {
                throw new ArgumentNullException("channel");
            }
            this.Channel = channel;

            if (data == null)
            {
                throw new ArgumentNullException("data");
            }
            this.ChannelBuffer = data;

            try
            {
                // Parse the sntp message
                this.RequestMessage = new SntpMessage(data.Buffer);

                // log that the packet was successfully parsed
                logger.Debug("PACKET with channel id " + this.Channel.ChannelId.ToString() +
                             " successfully parsed from client endpoint " + this.Channel.RemoteEndpoint.ToString());
                logger.Debug(RequestMessage.ToString());
            }
            catch (Exception ex)
            {
                logger.Error(ex, "Error parsing message:" + ex.Message.ToString());
                // disconnect ?
                return;
            }
        }
示例#2
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="ClientConnectedEventArgs" /> class.
        /// </summary>
        /// <param name="socket">The channel.</param>
        public SocketEventArgs(Socket socket)
        {
            if (socket == null)
            {
                throw new ArgumentNullException("socket");
            }

            Channel       = new SocketChannel();
            ChannelBuffer = new SocketBuffer();
            Channel.Assign(socket);
        }
示例#3
0
        /// <summary>
        ///     Initializes a new instance of the <see cref="ClientConnectedEventArgs" /> class.
        /// </summary>
        /// <param name="socket">The channel.</param>
        /// <param name="messageBuffer">The message buffer.</param>
        public ClientConnectedEventArgs(Socket socket, int messageBuffer)
        {
            if (socket == null)
            {
                throw new ArgumentNullException("socket");
            }

            AllowConnect = true;

            Channel       = new SocketChannel();
            ChannelBuffer = new SocketBuffer(messageBuffer);
            Channel.Assign(socket);
        }