Future<void> initialize() async { | |
String privateKey = await atProtocolService.getPrivateKey(atProtocolService.currentAtSign); | |
try { | |
atProtocolService.atClientImpl.startMonitor(privateKey, printResult); | |
} on ConnectionInvalidException catch (e){ | |
print('connection error: '+ e.toString()); | |
} | |
} | |
Future<void> printResult(String val) async { | |
print('Monitor result: ' + val.toString()); | |
getNewValue('one'); | |
} | |
Future<void> getNewValue(String key) async { | |
AtKey atKey = AtKey(); | |
atKey.key = key; | |
// Get keys shared by the other sign | |
atKey.sharedBy = AtConstants().atMap[atProtocolService.currentAtSign]; | |
try { | |
String serverValue = await atProtocolService.get(atKey); | |
print('Server value: ' + serverValue.toString()); | |
one = serverValue ?? '-'; | |
} on UnAuthenticatedException catch (e){ | |
print('auth error: '+ e.message); | |
} | |
notifyListeners(); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment