Iam create server with parse example here then use parse_server_sdk_flutter
Flutter Config
initServer() async {
await Parse().initialize({AppID}, {ParseServerUrl},
clientKey: {ParseClientKey},
debug: true,
coreStore: await CoreStoreSharedPrefsImp.getInstance(),
liveQueryUrl: {LiveQueryUrl},
autoSendSessionId: true);
}
//My Live Query Init:
void initState(){
queryChatList = QueryBuilder<ParseObject>(ParseObject('Messages'))
..whereEqualTo('idMsg', idMsg)
..setLimit(_limit)
..orderByDescending('date');
startLiveList();
}
void startLiveList() async {
debugPrint('init live');
subscription = await liveQuery.client.subscribe(queryChatList);
subscription.on(LiveQueryEvent.create, (value) {
debugPrint('*** CREATE ***: ${DateTime.now().toString()}\n $value ');
});
subscription.on(LiveQueryEvent.update, (value) {
debugPrint('*** UPDATE ***: ${DateTime.now().toString()}\n $value ');
});
subscription.on(LiveQueryEvent.delete, (value) {
debugPrint('*** DELETE ***: $value ');
});
}
Server Config:
let config = {
databaseURI: 'mongodb://localhost:27017/dev',
cloud: __dirname + '/cloud/main.js',
appId: 'AppId',
masterKey: 'masterKey',
serverURL: 'http://localhost:1337/srv',
liveQuery: {
classNames: ['Messages'],
redisURL: "redis://localhost:6379"
}
};
let liveQueryServerOptions ={
"appId": "AppId",
"masterKey": "masterKey",
"redisURL": "redis://localhost:6379",
"websocketTimeout": 10000,
"cacheTimeout": 36000000,
"logLevel": "VERBOSE"
}
let api = new ParseServer(config);
app.use('/srv', api.app);
var httpServer = require('http').createServer(app);
httpServer.listen(1337,function () {
console.log('server running on port 1337');
});
ParseServer.createLiveQueryServer(httpServer,liveQueryServerOptions);
My Log on dashboard:
2022-09-27T13:59:58.400Z - Can not find client undefined on disconnect
2022-09-27T13:59:58.399Z - Client disconnect: undefined
2022-09-27T13:54:29.959Z - Can not find client undefined on disconnect
2022-09-27T13:54:29.958Z - Client disconnect: undefined
- {ParseClientKey}, are we define this key on server side?
- My LiveQuery not detect changes on my class ‘Messages’ define on server, what wrong with my code, any tutorial or step by step on flutter?
Thanks