Search in sources :

Example 1 with ItemStateRequestMessage

use of org.creek.mailcontrol.model.message.ItemStateRequestMessage in project openhab1-addons by openhab.

the class MessagesProcessor method processReceivedMessages.

public void processReceivedMessages(Set<Object> messages) throws TransformException, ServiceException {
    logger.debug("Processing messages");
    for (Object msg : messages) {
        if (msg instanceof String) {
            logger.debug("Message: " + msg);
            GenericMessage message = requestTransformer.transform((String) msg);
            logger.debug("Processing message: " + message);
            if (message.getMessageType() == ITEM_COMMAND_REQUEST_MESSAGE) {
                ItemCommandData itemCommand = (ItemCommandData) ((ItemCommandRequestMessage) message).getItemCommand();
                itemCommandProcessor.processItemCommand(itemCommand);
            } else if (message.getMessageType() == ITEM_STATE_REQUEST_MESSAGE) {
                ItemStateRequestMessage itemStateRequestMessage = (ItemStateRequestMessage) message;
                ItemStateData itemState = itemStateRequestProcessor.getItemState(itemStateRequestMessage.getItemId());
                messagesSender.sendMessage(message, itemState);
            } else if (message.getMessageType() == ITEMS_STATE_REQUEST_MESSAGE) {
                List<ItemStateData> itemStates = itemStateRequestProcessor.getItemStates();
                messagesSender.sendMessage(message, itemStates);
            }
        }
    }
}
Also used : GenericMessage(org.creek.mailcontrol.model.message.GenericMessage) ItemStateRequestMessage(org.creek.mailcontrol.model.message.ItemStateRequestMessage) ItemStateData(org.creek.mailcontrol.model.data.ItemStateData) ItemCommandData(org.creek.mailcontrol.model.data.ItemCommandData)

Aggregations

ItemCommandData (org.creek.mailcontrol.model.data.ItemCommandData)1 ItemStateData (org.creek.mailcontrol.model.data.ItemStateData)1 GenericMessage (org.creek.mailcontrol.model.message.GenericMessage)1 ItemStateRequestMessage (org.creek.mailcontrol.model.message.ItemStateRequestMessage)1