setup method
Future<void>
setup({
- required Map<
String, dynamic Function(List< onFunctions,Object?> ? arg)> - required dynamic endpoint,
- dynamic runLogger = false,
- required Function getAuthToken,
- dynamic onClose({
- Exception? error,
- dynamic onReconnected({
- String? connectionId,
- dynamic onReconnecting({
- Exception? error,
- required Map<
String, List< invokes,Object> >
Implementation
Future<void> setup(
{required Map<String, Function(List<Object?>? arg)> onFunctions,
required endpoint,
runLogger = false,
required Function getAuthToken,
Function({Exception? error})? onClose,
Function({String? connectionId})? onReconnected,
Function({Exception? error})? onReconnecting,
required Map<String, List<Object>> invokes}) async {
_invokes = invokes;
_wsConnection = HubConnectionBuilder()
.withUrl(endpoint,
options: HttpConnectionOptions(
logger: _getLogger(runLogger),
logMessageContent: true,
requestTimeout: 10000,
accessTokenFactory: () => Future.value(getAuthToken()),
transport: HttpTransportType.WebSockets))
.withAutomaticReconnect()
.build();
if (onClose != null) _wsConnection!.onclose(onClose);
if (onReconnected != null) _wsConnection!.onreconnected(onReconnected);
if (onReconnecting != null) _wsConnection!.onreconnecting(onReconnecting);
connectToChannels(channels: onFunctions, invokes: invokes);
}