Kuzzle constructor
Kuzzle(
- KuzzleProtocol protocol, {
- bool autoQueue = false,
- bool autoReplay = false,
- bool autoResubscribe = true,
- bool deprecationWarnings = true,
- int eventTimeout = 200,
- OfflineMode offlineMode = OfflineMode.manual,
- Function? offlineQueueLoader,
- Function? queueFilter,
- Duration? queueTTL,
- int queueMaxSize = 500,
- Duration? replayInterval,
- Map<
String, dynamic> ? globalVolatile,
Implementation
Kuzzle(
this.protocol, {
this.autoQueue = false,
this.autoReplay = false,
this.autoResubscribe = true,
bool deprecationWarnings = true,
this.eventTimeout = 200,
this.offlineMode = OfflineMode.manual,
this.offlineQueueLoader,
this.queueFilter,
this.queueTTL,
this.queueMaxSize = 500,
this.replayInterval,
this.globalVolatile,
}) : deprecationHandler =
DeprecationHandler(deprecationWarning: deprecationWarnings) {
if (offlineMode == OfflineMode.auto) {
autoQueue = true;
autoReplay = true;
}
globalVolatile ??= <String, dynamic>{};
queueTTL ??= const Duration(minutes: 2);
replayInterval ??= const Duration(milliseconds: 10);
server = ServerController(this);
bulk = BulkController(this);
auth = AuthController(this);
index = IndexController(this);
collection = CollectionController(this);
document = DocumentController(this);
security = SecurityController(this);
realtime = RealTimeController(this);
protocol.on(ProtocolEvents.QUERY_ERROR, (error, request) {
emit(KuzzleEvents.QUERY_ERROR, [error, request]);
});
protocol.on(ProtocolEvents.NETWORK_ON_RESPONSE_RECEIVED,
(KuzzleResponse response) {
if (!_requests.contains(response.room)) {
emit(KuzzleEvents.UNHANDLED_RESPONSE, [response]);
}
if (response.error != null &&
response.error!.id == 'security.token.expired') {
jwt = null;
emit(KuzzleEvents.TOKEN_EXPIRED);
}
protocol.emit(response.room!, [response]);
});
}