Open method

Future<void> Open()
Opens this connection so it starts receiving events from the server. This results in a long-standing call to EWS.

Implementation

Future<void> Open() async {
  await _lockObject.synchronized(() async {
    ThrowIfDisposed();

    ValidateConnectionState(
      false,
      "Strings.CannotCallConnectDuringLiveConnection",
    );

    if (_subscriptions.isEmpty) {
      throw ServiceLocalException("Strings.NoSubscriptionsOnConnection");
    }

    _currentHangingRequest = GetStreamingEventsRequest(
      _session,
      HandleServiceResponseObject,
      _subscriptions.keys,
      _connectionTimeout,
    );

    _currentHangingRequest!.OnDisconnect.add(_OnRequestDisconnect);

    await _currentHangingRequest!.InternalExecute();
  });
}