function init() {
  this.wss.on('connection', (ws) => {
    let user;
    let authenticated = false;
    ws.on('close', () => {
      if (user) {
        this.userDisconnected(user, ws);
      }
    });
    ws.on('message', async (data) => {
      const parsedMessage = parseWebsocketMessage(data);
      switch (parsedMessage.type) {
        case WEBSOCKET_MESSAGE_TYPES.AUTHENTICATION.REQUEST:
          try {
            // we validate the token
            let payload;
            try {
              payload = this.gladys.session.validateAccessToken(parsedMessage.payload.accessToken, 'dashboard:write');
            } catch (e) {
              logger.debug(`Cannot validate websocket token with dashboard:write (${e}), trying with alarm:write`);
              payload = this.gladys.session.validateAccessToken(parsedMessage.payload.accessToken, 'alarm:write');
            }
            user = await this.gladys.user.getById(payload.user_id);
            authenticated = true;
            this.userConnected(user, ws);
          } catch (e) {
            ws.close(4000, ERROR_MESSAGES.INVALID_ACCESS_TOKEN);
          }
          break;
        default:
          logger.debug(`Message type not handled`);
      }
    });
    setTimeout(() => {
      if (authenticated === false) {
        ws.terminate();
      }
    }, 5000);
  });
  return null;
}
@description Init websocket server.
@returns {null} Returns when finished.
@example
init();