DBR701::ProcessInMessageFromReceiver

Windows CE 5.0 Not SupportedWindows Embedded NavReady 2009 Supported

10/16/2008

This virtual method processes a message that was accepted from the MSN Direct receiver. It is called internally to process a full frame every time a full frame is read from the MSN Direct receiver without errors.

You must override this virtual method in the DBR701 subclass and provide the appropriate message-handling algorithm. This algorithm must handle each supported message by creating the appropriate message object to be processed by the application, and sending an acknowledgement message to the MSN Direct receiver.

Syntax

virtual void ProcessInMessageFromReceiver(
  MsgFromReceiver *messageFromReceiver,
  GenericHostMsg *responseMessage
);

Parameters

  • messageFromReceiver
    [in] MsgFromReceiver object that represents the message that was accepted from the MSN Direct receiver.
  • responseMessage
    [in] GenericHostMsg object that will be processed into a reply that will be sent to the MSN Direct receiver. In a typical implementation, this value is passed into PrepareSimpleResponseMessage.

Return Value

None.

Remarks

The response message from this method is sent back to the MSN Direct receiver as the response to the input message. This function is called from one of the application-callback threads maintained by the DBR701 class.

You must override this virtual method in the DBR701 subclass and provide the appropriate message-handling algorithm. You can call GetApplicationType on the object returned in messageFromReceiver and then write separate message handlers for the case of each kind of MSN Direct service. The PrepareSimpleResponseMessage function should be called to handle each type of message.

For a complete example, view the source code for the MSN Direct sample application.

The ProcessInMessageFromReceiver method is invoked as a response to a previous request. A previous request occurs when the application calls the RequestSync method or because the receiver is sending new data to the host device. The programmer is expected to handle the messages received through ProcessInMessageFromReceiver and return the appropriate answer for each MSN Direct service type in the responseMessage output parameter.

Please note that this method is executed on one of the threads from the pool of application callback threads. Therefore, the programmer may have to use the appropriate thread-synchronization mechanisms when they are handling messages read from the receiver.

The sample application illustrates how to handle the MSN Direct protocol payload for the different type of MSN Direct services.

Example

The following code example shows you a starting point for overriding this virtual method.

void DBRHost::ProcessInMessageFromReceiver(
     MsgFromReceiver *messageFromReceiver, 
     GenericHostMsg *responseMessage)
{
     int App = messageFromReceiver->GetApplicationType();

     switch (App)
     {
          case PROTOCOL_ERROR :
          {
               ErrorMsg *pWm = (ErrorMsg *)messageFromReceiver;
               BYTE ErrorCode = ProcessError(pWm);
               // Prepare the response to the receiver
               PrepareSimpleResponseMessage(responseMessage,      
                 messageFromReceiver->GetTransactionId(), 
                 messageFromReceiver->GetApplicationType(), ErrorCode);
               return;
          }

          case GET_VERSION :
          {
          // Respond to the message from the receiver that has a 
          // GET_VERSION AppType

               return;
          }

          case POWER_STATUS :
          {
               // Respond to the message from the receiver that has a
               // POWER_STATUS AppType
               return;
          }

          case TUNING_DATA :
          {
               // Respond to the message from the receiver that has a
               // TUNING_DATA AppType
               return;
          }

          case FM_RADIO_STATUS :
          {
               // Respond to the message from the receiver that has a
               // FM_RADIO_STATUS AppType

               return;
          }

          case LOCATION_DATA :
          {
               // Respond to the message from the receiver that has a
               // LOCATION_DATA AppType

               return;
          }

          case LOCAL_TIME:
          {
               // Respond to the message from the receiver that has a
               // LOCAL_TIME AppType

               return;
          }
          case NON_LOCAL_WEATHER:
          {
               // Respond to the message from the receiver that has a
               // NON_LOCAL_WEATHER AppType

               return;
          }

          case WEATHER_ALERTS:
          {
               // Respond to the message from the receiver that has a
               // WEATHER_ALERTS AppType

               return;
          }

          case GAS_STATIONS:
          {
               // Respond to the message from the receiver that has a
               // GAS_STATIONS AppType

               return;
          }

          case GAS_PRICES:
          {
               // Respond to the message from the receiver that has a
               // GAS_PRICES AppType

               return;
          }

     // Prepare a simple response and no-error by default
     PrepareSimpleResponseMessage(responseMessage, 
          messageFromReceiver->GetTransactionId(), 
          messageFromReceiver->GetApplicationType(), APP_ERR_SUCCESS);
}

Requirements

Header DBR701.h
Library DBRLib.lib
Windows Embedded CE Windows CE 5.0, Windows Embedded NavReady 2009

See Also

Reference

DBR701::PrepareSimpleResponseMessage
DBR701 Class
MSN Direct Services Classes
MSN Direct Service Type Constants