private _sendUnsubscriptionMessage()

in packages/aws-appsync-subscription-link/src/realtime-subscription-handshake-link.ts [177:198]


  private _sendUnsubscriptionMessage(subscriptionId) {
    try {
      if (
        this.awsRealTimeSocket &&
        this.awsRealTimeSocket.readyState === WebSocket.OPEN &&
        this.socketStatus === SOCKET_STATUS.READY
      ) {
        // Preparing unsubscribe message to stop receiving messages for that subscription
        const unsubscribeMessage = {
          id: subscriptionId,
          type: MESSAGE_TYPES.GQL_STOP
        };
        const stringToAWSRealTime = JSON.stringify(unsubscribeMessage);
        this.awsRealTimeSocket.send(stringToAWSRealTime);

        this._removeSubscriptionObserver(subscriptionId);
      }
    } catch (err) {
      // If GQL_STOP is not sent because of disconnection issue, then there is nothing the client can do
      logger({ err });
    }
  }