Ejemplo n.º 1
0
        protected async Task <string> sendCommand(string command, Guid serverId)
        {
            var commandQueue = getCommandQueue(serverId);

            var queuedCommand = new QueuedCommand()
            {
                CommandString = command,
                ResultSource  = new TaskCompletionSource <string>(),
                NodeId        = serverId
            };

            commandQueue.Enqueue(queuedCommand);

            return(await queuedCommand.ResultSource.Task);
        }
Ejemplo n.º 2
0
        protected void handleRemoteCommand(NetworkStream stream, QueuedCommand serverCommand)
        {
            var emc = encryptMessage(serverCommand);

            emc.WriteToStream(stream);

            string response;

            using (MemoryStream ms = new MemoryStream())
            {
                stream.CopyTo(ms);
                ms.Position = 0;
                var emr = EncryptedMessage.FromStream(ms);
                response = decryptMessage(emr);
            }

            serverCommand.ResultSource.SetResult(response);
            stream.Close();
        }
Ejemplo n.º 3
0
 protected EncryptedMessage encryptMessage(QueuedCommand qc)
 {
     return(encryptMessage(qc.CommandString, qc.NodeId));
 }
Ejemplo n.º 4
0
 protected EncryptedMessage encryptMessage(QueuedCommand qc)
 {
     return encryptMessage(qc.CommandString, qc.NodeId);
 }
Ejemplo n.º 5
0
        protected async Task<string> sendCommand(string command, Guid serverId)
        {
            var commandQueue = getCommandQueue(serverId);

            var queuedCommand = new QueuedCommand()
            {
                CommandString = command,
                ResultSource = new TaskCompletionSource<string>(),
                NodeId = serverId
            };

            commandQueue.Enqueue(queuedCommand);

            return await queuedCommand.ResultSource.Task;
        }
Ejemplo n.º 6
0
        protected void handleRemoteCommand(NetworkStream stream, QueuedCommand serverCommand)
        {
            var emc = encryptMessage(serverCommand);
            emc.WriteToStream(stream);

            string response;

            using (MemoryStream ms = new MemoryStream())
            {
                stream.CopyTo(ms);
                ms.Position = 0;
                var emr = EncryptedMessage.FromStream(ms);
                response = decryptMessage(emr);
            }

            serverCommand.ResultSource.SetResult(response);
            stream.Close();
        }