subscribe method

  1. @override
Future<ClientSubscription> subscribe(
  1. String eventName
)
override

Request a ClientSubscription to the desired eventName from the server.

Implementation

@override
Future<ClientSubscription> subscribe(String eventName) {
  return _whenConnected<ClientSubscription>(() {
    var c = Completer<Map>();
    var requestId = _uuid.v4();
    _requests[requestId] = c;
    serverSendPort.send({
      'id': _id,
      'request_id': requestId,
      'method': 'subscribe',
      'params': {'client_id': clientId, 'event_name': eventName}
    });
    return c.future.then<ClientSubscription>((result) {
      _clientId = result['client_id'] as String?;
      var s = _IsolateClientSubscription(
          eventName, result['subscription_id'] as String?, this);
      _subscriptions.add(s);
      return s;
    });
  });
}