launch method
Future<RoomHandle>
launch(
- Future<
void> entry(- RoomLaunch launch
- required String roomId,
- int port = 0,
Implementation
Future<RoomHandle> launch(
Future<void> Function(RoomLaunch launch) entry, {
required String roomId,
int port = 0,
}) async {
if (_rooms.containsKey(roomId)) {
throw StateError('room already running ($roomId)');
}
final control = ReceivePort();
final isolate = await Isolate.spawn(_roomMain, (
entry,
roomId,
port,
control.sendPort,
), debugName: 'room-$roomId');
final boundPort = await control.first as int;
control.close();
final handle = RoomHandle._(roomId, boundPort, isolate);
_rooms[roomId] = handle;
return handle;
}