/// <summary> /// Start reception of trace on/off commands /// <para/> /// The given connection must be opened before this method is called. /// If the connection is closed the reception of backdoor commands is /// stopped. If a new connection is opened this method needs to be called /// in order to start reception of backdoor commands. /// <para/> /// In situations when a connection is regularly closed and reopened, /// for instance in the case of context switches, you should consider /// using a dedicated connection as parameter. /// </summary> /// <param name="connection">The connection used for setting up a subscription for /// backdoor commands.</param> public static void Start(Safir.Dob.ConnectionBase connection) { byte success; Safir.Dob.ConnectionAspectMisc misc = new Safir.Dob.ConnectionAspectMisc(connection); Library.SwreC_StartTraceBackdoor(System.Text.Encoding.UTF8.GetBytes(misc.GetConnectionNameCommonPart() + char.MinValue), System.Text.Encoding.UTF8.GetBytes(misc.GetConnectionNameInstancePart() + char.MinValue), out success); if (!Safir.Dob.Typesystem.Internal.InternalOperations.BoolOf(success)) { Safir.Dob.Typesystem.LibraryExceptions.Instance.Throw(); } }
void Safir.Dob.MessageSubscriber.OnMessage(Safir.Dob.MessageProxy messageProxy) { Safir.Dob.Message message = messageProxy.Message; Safir.Application.BackdoorCommand cmd = message as Safir.Application.BackdoorCommand; if (cmd == null) { // Unexpected message return; // *** RETURN *** } try { if (!cmd.NodeName.IsNull()) { if (!Regex.IsMatch(Safir.Dob.NodeParameters.Nodes(Safir.Dob.ThisNodeParameters.NodeNumber).NodeName.Val, cmd.NodeName.Val, RegexOptions.IgnoreCase)) { // Node name doesn't match return; // *** RETURN *** } } Safir.Dob.ConnectionAspectMisc connectionAspectMisc = new Safir.Dob.ConnectionAspectMisc(m_connection); if (!cmd.ConnectionName.IsNull()) { if (!Regex.IsMatch(connectionAspectMisc.GetConnectionName(), cmd.ConnectionName.Val, RegexOptions.IgnoreCase)) { // Connection name doesn't match return; // *** RETURN *** } } } catch (ArgumentException) { // An invalid regular expression was used, skip this command return; // *** RETURN *** } if (cmd.Command.IsNull()) { // No command given return; // *** RETURN *** } string[] cmdTokens = cmd.Command.Val.Split(new char[] { ' ', '\t', '\n', '\r' }, StringSplitOptions.RemoveEmptyEntries); if (cmdTokens.Length > 0) { if (cmdTokens[0].Equals("ping", StringComparison.OrdinalIgnoreCase)) { // It's a 'ping' command. Answer to it without bothering // the subclass implementator. Safir.Dob.ConnectionAspectMisc connectionAspectMisc = new Safir.Dob.ConnectionAspectMisc(m_connection); Safir.Logging.SendSystemLog(Safir.Logging.Severity.Debug, "Ping reply from " + connectionAspectMisc.GetConnectionName() + " on node " + Safir.Dob.NodeParameters.Nodes(Safir.Dob.ThisNodeParameters.NodeNumber).NodeName.Val); return; // *** RETURN *** } else if (cmdTokens[0].Equals("help", StringComparison.OrdinalIgnoreCase)) { // Get help text from subclass implementator. Safir.Logging.SendSystemLog(Safir.Logging.Severity.Debug, m_backdoor.GetHelpText()); return; // *** RETURN *** } } // Let the subclass handle the command m_backdoor.HandleCommand(cmdTokens); }