Inheritance: ConnectionEventArgs
Exemplo n.º 1
0
        protected virtual void OnDataSent(ConnectionDataEventArgs e)
        {
            var handler = DataSent;

            if (handler != null)
            {
                handler(this, e);
            }
        }
Exemplo n.º 2
0
 /// <summary>
 /// Client data recieve handler.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void Stratum_DataReceived(object sender, ConnectionDataEventArgs e)
 {
     var connection = (Connection)e.Connection;
     ((StratumMiner)connection.Client).Parse(e);
 }
Exemplo n.º 3
0
        protected virtual void OnDataSent(ConnectionDataEventArgs e)
        {
            var handler = DataSent;

            if (handler != null)
                handler(this, e);
        }
Exemplo n.º 4
0
        /// <summary>
        /// Parses the incoming data.
        /// </summary>
        /// <param name="e"></param>
        public void Parse(ConnectionDataEventArgs e)
        {
            Log.Verbose("RPC-client recv:\n{0}", e.Data.ToEncodedString());

            var rpcResultHandler = new AsyncCallback(
                callback =>
                {
                    var asyncData = ((JsonRpcStateAsync)callback);
                    var result = asyncData.Result + "\n"; // quick hack.
                    var response = Encoding.UTF8.GetBytes(result);

                    var context = (SocketsRpcContext) asyncData.AsyncState;
                    var miner = (StratumMiner)context.Miner;

                    miner.Connection.Send(response);

                    Log.Verbose("RPC-client send:\n{0}", result);
                });

            var line = e.Data.ToEncodedString();
            line = line.Replace("\n", ""); // quick hack!

            var rpcRequest = new SocketsRpcRequest(line);
            var rpcContext = new SocketsRpcContext(this, rpcRequest);

            var async = new JsonRpcStateAsync(rpcResultHandler, rpcContext) { JsonRpc = line };
            JsonRpcProcessor.Process(async, rpcContext);
        }