private void OnDataSent(ConnectionDataEventArgs e)
        {
            var handler = DataSent;

            if (handler != null)
            {
                handler(this, e);
            }
        }
        private void OnDataReceived(ConnectionDataEventArgs e)
        {
            var handler = DataReceived;

            if (handler != null)
            {
                handler(this, e);
            }
        }
        /// <summary>
        /// Parses the incoming data.
        /// </summary>
        /// <param name="e"></param>
        public void Parse(ConnectionDataEventArgs e)
        {
            var data = e.Data.ToEncodedString(); // read the data.
            var lines = Regex.Split(data, @"\r?\n|\r"); // get all lines with the recieved data.

            foreach (var line in lines) // loop through all lines
            {
                if (string.IsNullOrWhiteSpace(line)) // if line doesn't contain any data.
                    continue; // just skip it.

                ProcessRequest(line); // process the json-rpc request.
            }
        }
        /// <summary>
        /// Client data recieve handler.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void OnDataReceived(object sender, ConnectionDataEventArgs e)
        {
            if (e.Connection == null)
                return;

            var connection = (Connection) e.Connection;
            if (connection.Client == null)
                return;

            ((StratumMiner) connection.Client).Parse(e);
        }
        private void OnDataSent(ConnectionDataEventArgs e)
        {
            var handler = DataSent;

            if (handler != null)
                handler(this, e);
        }
        private void OnDataReceived(ConnectionDataEventArgs e)
        {
            var handler = DataReceived;

            if (handler != null)
                handler(this, e);
        }