Currently message handling on both gateway and portal is quite tedious. There's a lot of switch/case code that looks at at the type of message/event and decides in which direction to forward. This is typically either posting to a local EventBus (e.g., in PortalChannelHandler) or forwarding it to another host (e.g., the gateways).
By modifying iwsn-messages.proto we can introduce a distinction between upstream messages (from device/gateway to portal to client) and downstream messages (from client/portal towards devices/gateways. This would greatly simplify message/event handling code and result in cleaner implementations.
[x] Update iwsn-messages.proto
[x] Update PortalChannelHandler
[x] Update GatewayChannelHandler
[x] Update any other classes touched by this change
Apart from simplifying the handling code we can also simplify the way events are created (and e.g., wrapped by message objects). Ideally, it should e.g. only be allowed to post and retrieve high-level requests and events (such as FlashImageRequest and NodeOutputEvent) onto the EventBus instances and forbid to post / subscribe to wrapper types (e.g., Message, Event). The EventBus implementations could then be used to wrap/unwrap the high-level messages themselves so we can also remove noisy code from classes interacting with the EventBus interface. Consequently, the class MessagesHelper should afterwards probably only contain method to generate high-level events.
Currently message handling on both gateway and portal is quite tedious. There's a lot of switch/case code that looks at at the type of message/event and decides in which direction to forward. This is typically either posting to a local EventBus (e.g., in PortalChannelHandler) or forwarding it to another host (e.g., the gateways).
By modifying
iwsn-messages.proto
we can introduce a distinction between upstream messages (from device/gateway to portal to client) and downstream messages (from client/portal towards devices/gateways. This would greatly simplify message/event handling code and result in cleaner implementations.iwsn-messages.proto
Apart from simplifying the handling code we can also simplify the way events are created (and e.g., wrapped by message objects). Ideally, it should e.g. only be allowed to post and retrieve high-level requests and events (such as FlashImageRequest and NodeOutputEvent) onto the EventBus instances and forbid to post / subscribe to wrapper types (e.g., Message, Event). The EventBus implementations could then be used to wrap/unwrap the high-level messages themselves so we can also remove noisy code from classes interacting with the EventBus interface. Consequently, the class MessagesHelper should afterwards probably only contain method to generate high-level events.