GameBridgeSession constructor
GameBridgeSession({
- required GameBridge bridge,
- required String initJson(),
- required GameAsyncRunner async,
- required Future<
GameHttpOutcome> httpCall(), - required GameSkinStorage? storage,
- required String storageNamespace,
- required void haptics(
- String style
- required GameMotionSource sensors,
- required void onLog(),
- required void onCloseRequest(
- String style
- void onCta(
- String op
- void onHttpAnswer()?,
- GameHealthContext health = GameHealthContext.empty,
- void onHealth(
- EngageAnalyticsEvent event
- required void send(
- String style
- Future<
void> runActionSteps(- List<
EngageAction> actions
- List<
- EngageActionParser actionParser = const EngageActionParser(),
- void onHttpTimeout()?,
- GameWatchdogSchedule? watchdogSchedule,
- GameWatchdogCancel? watchdogCancel,
Implementation
GameBridgeSession({
required GameBridge bridge,
required String Function() initJson,
required GameAsyncRunner async,
required Future<GameHttpOutcome> Function(
String method, String path, Map<String, dynamic>? body)
httpCall,
required GameSkinStorage? storage,
required String storageNamespace,
required void Function(String style) haptics,
required GameMotionSource sensors,
required void Function(String level, String message) onLog,
required void Function(String reason) onCloseRequest,
void Function(String op)? onCta,
void Function(String path, Map<String, dynamic>? requestBody,
Map<String, dynamic>? responseBody)?
onHttpAnswer,
GameHealthContext health = GameHealthContext.empty,
void Function(EngageAnalyticsEvent event)? onHealth,
required void Function(String messageJson) send,
Future<void> Function(List<EngageAction> actions)? runActionSteps,
EngageActionParser actionParser = const EngageActionParser(),
void Function(String path, int durationMs)? onHttpTimeout,
GameWatchdogSchedule? watchdogSchedule,
GameWatchdogCancel? watchdogCancel,
}) : _bridge = bridge,
_initJson = initJson,
_async = async,
_httpCall = httpCall,
_storage = storage,
_storageNamespace = storageNamespace,
_haptics = haptics,
_sensors = sensors,
_onLog = onLog,
_onCloseRequest = onCloseRequest,
_onCta = onCta,
_onHttpAnswer = onHttpAnswer,
_health = health,
_onHealth = onHealth,
_send = send,
_runActionSteps = runActionSteps,
_actionParser = actionParser,
_onHttpTimeout = onHttpTimeout,
_watchdogSchedule =
watchdogSchedule ?? ((delay, fire) => Timer(delay, fire)),
_watchdogCancel = watchdogCancel ??
((handle) {
if (handle is Timer) handle.cancel();
}) {
_sensors.onSample = (sensor, x, y, z, t) {
if (_closed) return;
_sendSafe(jsonEncode({
'type': 'motionSample',
'payload': {
't': t,
sensor: {'x': x, 'y': y, 'z': z},
},
}));
};
}