use of im.actor.runtime.bser.DataOutput in project actor-platform by actorapp.
the class AbsContentContainer method buildContainer.
public byte[] buildContainer() throws IOException {
DataOutput res = new DataOutput();
BserWriter writer = new BserWriter(res);
if (this instanceof ContentLocalContainer) {
writer.writeInt(1, TYPE_LOCAL);
writer.writeBytes(2, ((ContentLocalContainer) this).getContent().buildContainer());
} else if (this instanceof ContentRemoteContainer) {
writer.writeInt(1, TYPE_REMOTE);
writer.writeBytes(2, ((ContentRemoteContainer) this).getMessage().buildContainer());
} else {
throw new IOException("Unknown type");
}
return res.toByteArray();
}
use of im.actor.runtime.bser.DataOutput in project actor-platform by actorapp.
the class ContactsSyncActor method saveList.
private void saveList() {
if (ENABLE_LOG) {
Log.d(TAG, "Saving contacts ids to storage");
}
DataOutput dataOutput = new DataOutput();
dataOutput.writeInt(contacts.size());
for (int l : contacts) {
dataOutput.writeInt(l);
}
preferences().putBytes("contact_list", dataOutput.toByteArray());
}
use of im.actor.runtime.bser.DataOutput in project actor-platform by actorapp.
the class JsKeyValueStorage method saveIndex.
private void saveIndex() {
DataOutput dataOutput = new DataOutput();
dataOutput.writeInt(items.size());
for (long l : items) {
dataOutput.writeLong(l);
}
storage.setItem("kv_" + prefix + "_index", toBase64(dataOutput.toByteArray()));
}
use of im.actor.runtime.bser.DataOutput in project actor-platform by actorapp.
the class JsListStorage method updateIndex.
private void updateIndex() {
Collections.sort(index, comparator);
DataOutput dataOutput = new DataOutput();
dataOutput.writeInt(index.size());
for (Index i : index) {
dataOutput.writeLong(i.getId());
dataOutput.writeLong(i.getSortKey());
}
storage.setItem("list_" + prefix + "_index", toBase64(dataOutput.toByteArray()));
}
use of im.actor.runtime.bser.DataOutput in project actor-platform by actorapp.
the class ManagedConnection method sendHandshakeRequest.
// Handshake
private synchronized void sendHandshakeRequest() {
// Log.d(TAG, "Starting handshake");
DataOutput handshakeRequest = new DataOutput();
handshakeRequest.writeByte(mtprotoVersion);
handshakeRequest.writeByte(apiMajorVersion);
handshakeRequest.writeByte(apiMinorVersion);
handshakeRandomData = new byte[32];
synchronized (RANDOM) {
RANDOM.nextBytes(handshakeRandomData);
}
handshakeRequest.writeInt(handshakeRandomData.length);
handshakeRequest.writeBytes(handshakeRandomData, 0, handshakeRandomData.length);
handshakeTimeout.schedule(HANDSHAKE_TIMEOUT);
rawPost(HEADER_HANDSHAKE_REQUEST, handshakeRequest.toByteArray());
}
Aggregations