setup method

  1. @override
Future setup(
  1. void onSetupComplete(),
  2. void onSetupFailed()
)
override

Implementation

@override
Future setup(
    void Function() onSetupComplete, void Function() onSetupFailed) async {
  try {
    _socket = io.io(
        socketioServerLocation +
            CeleryvizOptions.config.socketioClientEndpoint,
        <String, dynamic>{
          'transports': ['websocket'],
        });
    _socketInitialized = true;
    _socket.onConnect((data) => {
          onSetupComplete(),
        });
    _socket.onConnectError((err) => {
          onSetupFailed(),
        });
    _socket.onError((err) => {
          onSetupFailed(),
        });

    _socket.on(CeleryvizOptions.config.socketioServerDataEvent,
        (data) => _sendEventsToBloc([data]));
    _socket.connect();
  } catch (e) {
    onSetupFailed();
  }
}