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); }
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(); }
protected EncryptedMessage encryptMessage(QueuedCommand qc) { return(encryptMessage(qc.CommandString, qc.NodeId)); }
protected EncryptedMessage encryptMessage(QueuedCommand qc) { return encryptMessage(qc.CommandString, qc.NodeId); }
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; }