This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void externalize(DataOutputStream out) throws IOException { | |
out.writeUTF(name); | |
if(value != null) { | |
out.writeBoolean(true); | |
out.writeUTF(value); | |
} else { | |
out.writeBoolean(false); | |
} | |
if(domain != null) { | |
out.writeBoolean(true); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public int getVersion(); | |
public void externalize(DataOutputStream out) throws IOException; | |
public void internalize(int version, DataInputStream in) throws IOException; | |
public String getObjectId(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Util.register("MyClass", MyClass.class); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Map<String, Object> h = new HashMap<>(); | |
h.put("Hi","World"); | |
h.put("data", new byte[] {(byte)1}); | |
Storage.getInstance().writeObject("Test", h); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ConnectionRequest request = new ConnectionRequest(url, false); | |
request.setFailSilently(true); | |
NetworkManager.getInstance().addToQueueAndWait(request); | |
if(request.getResponseCode() != 200) { | |
// probably an error... | |
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ConnectionRequest request = new ConnectionRequest(url, false) { | |
protected void handleErrorResponseCode(int code, String message) { | |
if(code == 444) { | |
// do something | |
} | |
} | |
protected void readResponse(InputStream input) { | |
// just read from the response input stream | |
} | |
}; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
NetworkManager.getInstance().addToQueue(request); | |
NetworkManager.getInstance().addErrorListener((e) -> e.consume()); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
ConnectionRequest request = new ConnectionRequest(url, false) { | |
protected void readHeaders(Object connection) throws IOException { | |
String[] headerNames = getHeaderFieldNames(connection); | |
for(String headerName : headerNames) { | |
String headerValue = getHeader(headerName); | |
//.... | |
} | |
} | |
protected void readResponse(InputStream input) { | |
// just read from the response input stream |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String authCode = user + ":" + password; | |
String authHeader = "Basic " + Base64.encode(authCode.getBytes()); | |
NetworkManager.getInstance().addDefaultHeader("Authorization", authHeader); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
String authCode = user + ":" + password; | |
String authHeader = "Basic " + Base64.encode(authCode.getBytes()); | |
request.addRequestHeader("Authorization", authHeader); |