/// <summary>
        /// Fires the ReadCompleted event for the connection with the given Id
        /// </summary>
        /// <param name="connectionId">The connection Id on which the read operation completed</param>
        /// <param name="memoryStream">The data read represented as a MemoryStream object</param>
        protected void OnReadCompleted(int connectionId, MemoryStream memoryStream)
        {
            if (this.ReadCompleted != null)
            {
                AsyncReadEventArgs args = new AsyncReadEventArgs()
                {
                    ConnectionId  = connectionId,
                    MessageStream = memoryStream
                };

                // Fire the event
                this.ReadCompleted(this, args);
            }
        }
Exemple #2
0
        /// <summary>
        /// Fires the ReadCompleted event for the connection with the given Id
        /// </summary>
        /// <param name="connectionId">The connection Id on which the read operation completed</param>
        /// <param name="memoryStream">The data read represented as a MemoryStream object</param>
        protected void OnReadCompleted(int connectionId, MemoryStream memoryStream)
        {
            if (this.ReadCompleted != null)
            {
                var formatter = new BinaryFormatter();
                var message   = (MockMessage)formatter.Deserialize(memoryStream);

                AsyncReadEventArgs args = new AsyncReadEventArgs()
                {
                    ConnectionId  = connectionId,
                    MessageStream = memoryStream,
                    Message       = message
                };

                // Fire the event
                this.ReadCompleted(this, args);
            }
        }