getSession method

  1. @override
Future<Session> getSession(
  1. String idOrCode
)
override

Fetches a session by its ID or by a 6 digit code. When loaded the callback will be invoked with the session object, or an error if the session could not be fetched.

Throws a PlatformException if the session cannot be fetched (e.g. no network connection or the ID is not valid).

Implementation

@override
Future<Session> getSession(String idOrCode) async {
  Map? rvalue;
  try {
    rvalue = await methodChannel.invokeMapMethod('getSession', idOrCode);
  } on PlatformException catch (e) {
    print('Cannot get session: $e');
    rethrow;
  }
  if (rvalue == null) {
    throw PlatformException(
        code: 'COBROWSE_IO_ERROR', message: 'getSession failed');
  }
  return Session._build(rvalue);
}