Example #1
0
        protected async Task handleLocalCommand(NetworkStream stream, Guid remoteId)
        {
            string command;

            var emc = EncryptedMessage.FromStream(stream);

            command = decryptMessage(emc);

            _log.Debug($"Got command \"{command.Truncate(10)}\".");

            var crea = new CommandReceivedEventArgs()
            {
                Command      = command,
                NodeId       = remoteId,
                ResultSource = new TaskCompletionSource <string>()
            };

            CommandReceived(this, crea);

            var response = await crea.ResultSource.Task;

            try {
                var emr = encryptMessage(response, remoteId);
                emr.WriteToStream(stream);
            }
            catch (Exception x)
            {
                _log.Warn($"Could not send response: {x.Message}");
                throw x;
            }

            stream.Close();
        }
 private static void NodeB_CommandReceived(object sender, Nemesis.CommandReceivedEventArgs e)
 {
     e.ResultSource.SetResult("Node B Result");
 }
 private static void Hub_CommandReceived(object sender, Nemesis.CommandReceivedEventArgs e)
 {
     e.ResultSource.SetResult(String.Format("Client Result from {0}", e.NodeId));
 }
Example #4
0
        protected async Task handleLocalCommand(NetworkStream stream, Guid remoteId)
        {

            string command;

            var emc = EncryptedMessage.FromStream(stream);
            command = decryptMessage(emc);

            _log.Debug($"Got command \"{command.Truncate(10)}\".");

            var crea = new CommandReceivedEventArgs()
            {
                Command = command,
                NodeId = remoteId,
                ResultSource = new TaskCompletionSource<string>()
            };

            CommandReceived(this, crea);

            var response = await crea.ResultSource.Task;

            try {
                var emr = encryptMessage(response, remoteId);
                emr.WriteToStream(stream);
            }
            catch (Exception x)
            {
                _log.Warn($"Could not send response: {x.Message}");
                throw x;
            }

            stream.Close();
        }