Search in sources :

Example 1 with DataOutput

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();
}
Also used : DataOutput(im.actor.runtime.bser.DataOutput) BserWriter(im.actor.runtime.bser.BserWriter) IOException(java.io.IOException)

Example 2 with DataOutput

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());
}
Also used : DataOutput(im.actor.runtime.bser.DataOutput)

Example 3 with DataOutput

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()));
}
Also used : DataOutput(im.actor.runtime.bser.DataOutput)

Example 4 with DataOutput

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()));
}
Also used : DataOutput(im.actor.runtime.bser.DataOutput)

Example 5 with DataOutput

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());
}
Also used : DataOutput(im.actor.runtime.bser.DataOutput)

Aggregations

DataOutput (im.actor.runtime.bser.DataOutput)12 BserWriter (im.actor.runtime.bser.BserWriter)4 IOException (java.io.IOException)3 CommonTimer (im.actor.runtime.threading.CommonTimer)2 EncryptedCBCPackage (im.actor.core.network.mtp.entity.EncryptedCBCPackage)1 EncryptedPackage (im.actor.core.network.mtp.entity.EncryptedPackage)1 Digest (im.actor.runtime.crypto.Digest)1