Skip to content

1.0.1 DataMessageHandler

Anders Mikkelsen edited this page Dec 16, 2017 · 2 revisions

DataMessageHandler

This is one of the optional components used by the FcmServer class, and its builder. This interface defines what the server should do upon reception of a message that is not linked to registration, e.g. business logic. It also contains setters for both server and sender, as well as a getter for a RegistrationService.

All messages are handled by a field in the data object called "action". These are the default actions pertaining to registering devices:

switch (action) {
    case REGISTER_DEVICE
        getRegistrationService().registerDevice(msg.getCategory(), gcmId, data);
        
        break;
    case UPDATE_ID:
        getRegistrationService().update(msg.getCategory(), gcmId, data);
          
        break;
    case PONG:           
        logger.info("Device is alive...");    
        setDeviceAlive(data);
         
        break;
    default:
        handleIncomingDataMessage(msg);

        break;
}

All business logic will be handled in the overriden handleIncomingDataMessage method.