connect method
void
connect()
Connect to the broadcast WebSocket
Implementation
void connect() {
_reconnecting = ReconnectingWebSocket(url, {
'api_key': apiKey,
if (userId != null) 'user_id': userId,
if (userName != null) 'user_name': userName,
});
_reconnecting!.connect();
_reconnecting!.onMessage((ev) {
final data = jsonDecode(ev.data as String) as Map<String, dynamic>;
if (data['type'] == 'message') {
for (final callback in _listeners) {
callback(data);
}
}
});
}