connect method
Establishes connection to the server.
Usually all event listeners should be already attached when this method is invoked.
Returns a Future which resolves when the first connection attempt is carried out. However, note that connection may not always succeed on the first attempt — for state changes, do rely on the events instead.
Implementation
Future<ConnectionState> connect() {
if (_connectHasBeenCalled != false) {
throw StateError('Kabelwerk is already ${_connector.state}.');
}
_connectHasBeenCalled = true;
_connector.prepareSocket();
_setUpChannel();
return _connector.connect();
}