com.infomaximum.network.protocol.standard.packet.RequestPacket Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of network Show documentation
Show all versions of network Show documentation
Library for creating a light http server
package com.infomaximum.network.protocol.standard.packet;
import net.minidev.json.JSONObject;
/**
* Created by kris on 26.08.16.
*/
public class RequestPacket extends TargetPacket implements IPacketId {
private final long id;
public RequestPacket(long id, String controller, String action, JSONObject data) {
super(controller, action, data);
this.id=id;
}
public RequestPacket(JSONObject parse) {
super(
parse.getAsString("controller"),
parse.getAsString("action"),
(JSONObject) parse.get("data")
);
this.id = parse.getAsNumber("id").longValue();
}
@Override
public TypePacket getType() {
return TypePacket.REQUEST;
}
@Override
public long getId() {
return id;
}
@Override
protected void serializeNative(JSONObject jsonObject) {
super.serializeNative(jsonObject);
jsonObject.put("id", id);
}
}