connect method
Starts to listen on the given socket.
This is mainly useful for testing purposes, ensure to set
connectionInformation manually in this case, e.g.
await client.connect(socket, connectionInformation:
ConnectionInfo(host, port, isSecure));
Implementation
void connect(Socket socket, {ConnectionInfo? connectionInformation}) {
if (connectionInformation != null) {
connectionInfo = connectionInformation;
_greetingsCompleter = Completer<ConnectionInfo>();
}
_socket = socket;
_writeFuture = null;
// if (connectionTimeout != null) {
// final timeoutStream = socket.timeout(connectionTimeout!);
// _socketStreamSubscription = timeoutStream.listen(
// _onDataReceived,
// onDone: onConnectionDone,
// onError: _onConnectionError,
// );
// } else {
_socketStreamSubscription = socket.listen(
_onDataReceived,
onDone: onConnectionDone,
onError: _onConnectionError,
);
// }
_isConnected = true;
isSocketClosingExpected = false;
}