org.telegram.mtproto.tl.pq.ReqPQ Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of telegramapi Show documentation
Show all versions of telegramapi Show documentation
Java library to create Telegram Clients
The newest version!
package org.telegram.mtproto.tl.pq;
import org.telegram.tl.DeserializeException;
import org.telegram.tl.TLContext;
import org.telegram.tl.TLMethod;
import org.telegram.tl.TLObject;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import static org.telegram.tl.StreamingUtils.readBytes;
import static org.telegram.tl.StreamingUtils.writeByteArray;
/**
* Created with IntelliJ IDEA.
* User: Ruben Bermudez
* Date: 03.11.13
* Time: 4:17
*/
public class ReqPQ extends TLMethod {
public static final int CLASS_ID = 0x60469778;
protected byte[] nonce;
public ReqPQ(byte[] nonce) {
if (nonce == null || nonce.length != 16) {
throw new IllegalArgumentException("nonce might be not null and 16 bytes length");
}
this.nonce = nonce;
}
public ReqPQ() {
}
@Override
public ResPQ deserializeResponse(InputStream stream, TLContext context) throws IOException {
TLObject response = context.deserializeMessage(stream);
if (response == null) {
throw new DeserializeException("Unable to deserialize response");
}
if (!(response instanceof ResPQ)) {
throw new DeserializeException("Response has incorrect type");
}
return (ResPQ) response;
}
public byte[] getNonce() {
return this.nonce;
}
public void setNonce(byte[] nonce) {
if (nonce == null || nonce.length != 16) {
throw new IllegalArgumentException("nonce might be not null and 16 bytes length");
}
this.nonce = nonce;
}
@Override
public int getClassId() {
return CLASS_ID;
}
@Override
public void serializeBody(OutputStream stream) throws IOException {
writeByteArray(this.nonce, stream);
}
@Override
public void deserializeBody(InputStream stream, TLContext context) throws IOException {
this.nonce = readBytes(16, stream);
}
@Override
public String toString() {
return "req_pq#60469778";
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy