Пример #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);
        }
Пример #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();
        }
Пример #3
0
 protected EncryptedMessage encryptMessage(QueuedCommand qc)
 {
     return(encryptMessage(qc.CommandString, qc.NodeId));
 }
Пример #4
0
 protected EncryptedMessage encryptMessage(QueuedCommand qc)
 {
     return encryptMessage(qc.CommandString, qc.NodeId);
 }
Пример #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;
        }
Пример #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();
        }