Socket connection is not closed, then navigate back to Launchpad

Viewed 114

I have an Fiori Elements application, which consumes an Socket connection over the object:

sap/ui/core/ws/WebSocket

If an message is send to the Frontend, the App shows an PopUp.

Problem:

  1. User uses APP
  2. User navigates to Launchpad
  3. Socket connection is not closed
  4. Message is send by Socket
  5. PopUp is shown in Launchpad Launchpad with PopUp

How can I achieve that no PopUp is displayed?

2 Answers

Solution was simple, implement onExit method of Controller would do the trick

onExit() {
  this.socket.close();
}

In case if a WebSocket object is created in the Component.js, be sure that the WebSocket is initialized in the Component init() function and call the WebSocket close() method in the Component exit() function.

Related