public void Close(string message) { VariableCollection vars = new VariableCollection(); vars.Add("message", message); var obj = new JukeboxMessage { Type = "close", Variables = vars, MessageId = -1 }; WriteMessage(obj); Context.Disconnect(); }
public VariableCollection Invoke(string commandId, VariableCollection variables) { if (variables == null) variables = new VariableCollection(); var context = this.Context; if (context == null) throw new IOException("Connection not open"); variables.Add("commandId", commandId); var obj = new JukeboxMessage { Type = "command", Variables = variables, MessageId = GetNewId() }; var response = InvokeCore(obj); return (response); }
private VariableCollection InvokeCore(JukeboxMessage obj) { var pendingRequest = new PendingRequest { Id = obj.MessageId }; lock (pendingRequests) pendingRequests.Add(pendingRequest); WriteMessage(obj); var response = WaitResponse(pendingRequest); return (response); }
private void HandleResponse(JukeboxMessage dispatcherObject) { lock (pendingRequests) { var pendingRequest = GetPendingRequest(dispatcherObject.MessageId); pendingRequest.Signal(dispatcherObject.Variables); } }
private void HandleRequest(JukeboxMessage dispatcherObject) { var commandId = dispatcherObject.Variables.GetValue<string>("commandId"); ts.TraceEvent(TraceEventType.Verbose, 0, "Received request '{0}'", commandId); if (!handlers.ContainsKey(commandId)) { ts.TraceEvent(TraceEventType.Error, 0, "Unknown command '{0}'", commandId); return; } var handler = handlers[commandId]; handler(dispatcherObject.Variables); }
private void HandleError(JukeboxMessage dispatcherObject) { var pendingRequest = GetPendingRequest(dispatcherObject.MessageId); var errorMessage = dispatcherObject.Variables.GetValue<string>("message"); pendingRequest.Signal(new RemotingException(errorMessage ?? string.Empty)); }