@Override public void put(KContentPutRequest request, KCallback<Throwable> error) { PutRequest putRequest = new PutRequest(); putRequest.request = request; putRequest.id = nextKey(); _callbacks.put(putRequest.id, error); WebSockets.sendText(putRequest.json(), _client.getChannel(), null); }
@Override public void get(KContentKey[] keys, KCallback<String[]> callback) { GetRequest getRequest = new GetRequest(); getRequest.keys = keys; getRequest.id = nextKey(); _callbacks.put(getRequest.id, callback); WebSockets.sendText(getRequest.json(), _client.getChannel(), null); }
@Override public void atomicGetIncrement(KContentKey key, KCallback<Short> callback) { AtomicGetIncrementRequest atomicGetRequest = new AtomicGetIncrementRequest(); atomicGetRequest.id = nextKey(); atomicGetRequest.key = key; _callbacks.put(atomicGetRequest.id, callback); WebSockets.sendText(atomicGetRequest.json(), _client.getChannel(), null); }
@Override public void close(KCallback<Throwable> callback) { _client.close(); callback.on(null); }
@Override public void connect(KCallback<Throwable> callback) { _client.connect(this); _atomicInteger = new AtomicInteger(); callback.on(null); }
@Override public void send(KMessage msg) { _localEventListeners.dispatch(msg); WebSockets.sendText(msg.json(), _client.getChannel(), null); }