Service Worker Communication

ActiveSense uses Intents for its Communication between Activities / Services. At the Moment, ActiveSense utilized this pattern when communicating between the ServiceWorker coordinating the Measuring of Data and the MeasureActivity, which is userfacing. This section outlines the communication process between the user interface (MeasureActivity), the service responsible for handling WebSocket connections (Service), and the backend (Backend), which receives the measured data.

sequenceDiagram
    autonumber
    participant Activity as MeasureActivity
    participant Service as Service (WebSocket Handler)
    participant Backend as Backend (WebSocket)
    Activity ->> Service: Invoke Service
    Activity ->> Activity: Start Listening to Websocket Updates
    Service ->> Backend: Establish WebSocket Connection
    Service ->> Activity: Intent("de.hsrm.activesense.WEBSOCKET_CONNECTION",<br> "CONNECTION_STATE": IPCState.IDLE )
    Backend -->> Service: Send start commands via WebSocket
    Service ->> Activity: Intent("de.hsrm.activesense.WEBSOCKET_CONNECTION",<br> "CONNECTION_STATE": IPCState.TRANSMITTING )
    opt Websocket Conneciton fails
        Backend --> Service: Connection-Failure
        Service ->> Activity: Intent("de.hsrm.activesense.WEBSOCKET_CONNECTION", <br> "CONNECTION_STATE": IPCState.FAILED, <br> "CONNECTION_MESSAGE: IPCMessage.*)
    end
    Service ->> Activity: Intent("de.hsrm.activesense.WEBSOCKET_CONNECTION", <br> "CONNECTION_STATE": IPCState.CLOSED)