//StartRemoveInExercise8 /// <summary> /// Overrides Safir.Dob.MessageSubscriber. Called by the Dob /// when a message is sent that is subscribed for. /// </summary> public void OnMessage(Safir.Dob.MessageProxy messageProxy) { Capabilities.Vehicles.VehicleMsg msg = (Capabilities.Vehicles.VehicleMsg)messageProxy.Message; if (!msg.MessageText.IsNull()) { labelMessage.Text = msg.MessageText.Val.ToString(); } else { labelMessage.Text = "No text in received message"; } this.Show(); }
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); }