private void StopCmd(AbstractCommand command) { lock (_active_commands) { _active_commands.Remove(command.CmdNr); } }
private void StartCmd(AbstractCommand command) { lock (_active_commands) { _active_commands[command.CmdNr] = command; } }
public void SendStream(AbstractCommand cmd, JObject data) { var msg = new JObject { { "type", "stream" }, { "nr", Interlocked.Increment(ref _command_counter) }, { "cmd-nr", cmd.CmdNr }, { "id", cmd.Name }, { "data", data }, }; SendText(JsonConvert.SerializeObject(msg)); }
private void RegisterCommand(string name, AbstractCommand c, Type type, bool is_alias = false) { if (Commands.ContainsKey(name)) { var existing = Commands[name]; if (existing.Version > c.Version) // if version is equal, overwrite (due to compatibility). to ensure against overwriting, increase version number of the command. { return; } } Commands[name] = new CommandInfo { Name = name, InstructionSet = c.InstructionSet, Version = c.Version, Type = type, IsAlias = is_alias, }; }