mirror of
https://github.com/ChronosX88/JGUN.git
synced 2024-11-09 16:51:02 +00:00
refactor: Change name of get data in request json
This commit is contained in:
parent
eca5e03b6f
commit
b980bbd2b3
@ -36,7 +36,7 @@ public class Dispatcher {
|
|||||||
JSONObject ack = handlePut(message);
|
JSONObject ack = handlePut(message);
|
||||||
peer.emit(ack.toString());
|
peer.emit(ack.toString());
|
||||||
}
|
}
|
||||||
if(message.has("await")) {
|
if(message.has("get")) {
|
||||||
JSONObject ack = handleGet(message);
|
JSONObject ack = handleGet(message);
|
||||||
peer.emit(ack.toString());
|
peer.emit(ack.toString());
|
||||||
}
|
}
|
||||||
@ -47,7 +47,7 @@ public class Dispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private JSONObject handleGet(JSONObject getData) {
|
private JSONObject handleGet(JSONObject getData) {
|
||||||
InMemoryGraph getResults = Utils.getRequest(getData.getJSONObject("await"), graphStorage);
|
InMemoryGraph getResults = Utils.getRequest(getData.getJSONObject("get"), graphStorage);
|
||||||
return new JSONObject() // Acknowledgment
|
return new JSONObject() // Acknowledgment
|
||||||
.put( "#", dup.track(Dup.random()) )
|
.put( "#", dup.track(Dup.random()) )
|
||||||
.put( "@", getData.getString("#") )
|
.put( "@", getData.getString("#") )
|
||||||
@ -56,23 +56,11 @@ public class Dispatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private JSONObject handlePut(JSONObject message) {
|
private JSONObject handlePut(JSONObject message) {
|
||||||
InMemoryGraph diff = HAM.mix(new InMemoryGraph(message.getJSONObject("put")), graphStorage);
|
boolean success = HAM.mix(new InMemoryGraph(message.getJSONObject("put")), graphStorage, changeListeners, forEachListeners);
|
||||||
if(diff != null) {
|
|
||||||
for(Map.Entry<String, Node> entry : diff.entries()) {
|
|
||||||
if(changeListeners.containsKey(entry.getKey())) {
|
|
||||||
changeListeners.get(entry.getKey()).onChange(entry.getValue().toUserJSONObject());
|
|
||||||
}
|
|
||||||
if(forEachListeners.containsKey(entry.getKey())) {
|
|
||||||
for(Map.Entry<String, Object> jsonEntry : entry.getValue().values.toMap().entrySet()) {
|
|
||||||
forEachListeners.get(entry.getKey()).onChange(jsonEntry.getKey(), jsonEntry.getValue());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
return new JSONObject() // Acknowledgment
|
return new JSONObject() // Acknowledgment
|
||||||
.put( "#", dup.track(Dup.random()) )
|
.put( "#", dup.track(Dup.random()) )
|
||||||
.put( "@", message.getString("#") )
|
.put( "@", message.getString("#") )
|
||||||
.put( "ok", true);
|
.put( "ok", success);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void handleIncomingAck(JSONObject ack) {
|
private void handleIncomingAck(JSONObject ack) {
|
||||||
|
@ -97,7 +97,7 @@ public class Utils {
|
|||||||
if(field != null) {
|
if(field != null) {
|
||||||
getParameters.put(".", field);
|
getParameters.put(".", field);
|
||||||
}
|
}
|
||||||
jsonObject.put("await", getParameters);
|
jsonObject.put("get", getParameters);
|
||||||
return jsonObject;
|
return jsonObject;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user