emit method

void emit({
  1. required String event,
  2. dynamic data,
  3. void onResponse(
    1. dynamic response
    )?,
  4. void onError(
    1. dynamic response
    )?,
})

Implementation

void emit({
  required String event,
  dynamic data,
  void Function(dynamic response)? onResponse,
  void Function(dynamic error)? onError,
}) {
  interceptors.onSend(event, data);

  final polling = _polling;
  if (polling == null || !polling.isConnected) {
    onError?.call('Socket is not initialized');
    return;
  }

  try {
    polling.emit(event, data, onResponse: onResponse);
  } catch (e) {
    interceptors.onError(event, e);
    onError?.call(e);
  }
}