import 'dart:ffi';
import 'package:ffi/ffi.dart';
import 'dart:typed_data';
import 'tmg_load_dynamic.dart';

typedef GetRoomIDNative = Pointer<Int8> Function();
typedef GetRoomIDDart = Pointer<Int8> Function();

class TMGRoomBindings {
  TMGLoadDynamic _tmgDynamicInstance = TMGLoadDynamic.GetInstance();
  DynamicLibrary? _gmeSdkLib = null;

  TMGRoomBindings() {
    _gmeSdkLib = _tmgDynamicInstance.GetGmeSdkLib();
  }

  late final GetRoomIDDart GetRoomIDPtr = _gmeSdkLib!
      .lookup<NativeFunction<GetRoomIDNative>>('QAVSDK_AVRoom_GetRoomID')
      .asFunction<GetRoomIDDart>();

  String GetRoomID() {
    return GetRoomIDPtr().cast<Utf8>().toDartString();
  }
}
