Изменения протокола по вложениям и новый Steram
This commit is contained in:
@@ -4,6 +4,8 @@ import java.util.List;
|
||||
|
||||
import im.rosetta.packet.base.PacketBaseDialog;
|
||||
import im.rosetta.packet.runtime.Attachment;
|
||||
import im.rosetta.packet.runtime.AttachmentEncoding;
|
||||
import im.rosetta.packet.runtime.AttachmentTransport;
|
||||
import im.rosetta.packet.runtime.AttachmentType;
|
||||
|
||||
import io.orprotocol.Stream;
|
||||
@@ -58,7 +60,13 @@ public class Packet6Message extends PacketBaseDialog {
|
||||
String preview = stream.readString();
|
||||
String blob = stream.readString();
|
||||
AttachmentType type = AttachmentType.fromCode(stream.readInt8());
|
||||
this.attachments.add(new Attachment(id, blob, type, preview));
|
||||
String transportTag = stream.readString();
|
||||
String transportServer = stream.readString();
|
||||
AttachmentTransport transport = new AttachmentTransport(transportTag, transportServer);
|
||||
String encodedFor = stream.readString();
|
||||
String encoder = stream.readString();
|
||||
AttachmentEncoding encoding = new AttachmentEncoding(encoder, encodedFor);
|
||||
this.attachments.add(new Attachment(id, blob, type, preview, encoding, transport));
|
||||
}
|
||||
this.aesChachaKey = stream.readString();
|
||||
}
|
||||
@@ -80,6 +88,10 @@ public class Packet6Message extends PacketBaseDialog {
|
||||
stream.writeString(attachment.getPreview());
|
||||
stream.writeString(attachment.getBlob());
|
||||
stream.writeInt8((byte) attachment.getType().getCode());
|
||||
stream.writeString(attachment.getTransport().getTransportTag());
|
||||
stream.writeString(attachment.getTransport().getTransportServer());
|
||||
stream.writeString(attachment.getEncoding().getEncoder());
|
||||
stream.writeString(attachment.getEncoding().getEncodedFor());
|
||||
}
|
||||
stream.writeString(this.aesChachaKey);
|
||||
return stream;
|
||||
|
||||
@@ -9,12 +9,16 @@ public class Attachment {
|
||||
private String blob;
|
||||
private AttachmentType type;
|
||||
private String preview;
|
||||
private AttachmentEncoding encoding;
|
||||
private AttachmentTransport transport;
|
||||
|
||||
public Attachment(String id, String blob, AttachmentType type, String preview) {
|
||||
public Attachment(String id, String blob, AttachmentType type, String preview, AttachmentEncoding encoding, AttachmentTransport transport) {
|
||||
this.id = id;
|
||||
this.blob = blob;
|
||||
this.type = type;
|
||||
this.preview = preview;
|
||||
this.encoding = encoding;
|
||||
this.transport = transport;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -49,4 +53,20 @@ public class Attachment {
|
||||
return preview;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить информацию о том, как было закодировано вложение
|
||||
* @return
|
||||
*/
|
||||
public AttachmentEncoding getEncoding() {
|
||||
return encoding;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить информацию о том, как доставлять вложение
|
||||
* @return
|
||||
*/
|
||||
public AttachmentTransport getTransport() {
|
||||
return transport;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package im.rosetta.packet.runtime;
|
||||
|
||||
/**
|
||||
* Класс для хранения информации о том, как было закодировано вложение в сообщении
|
||||
*/
|
||||
public class AttachmentEncoding {
|
||||
|
||||
private String encoder;
|
||||
private String encodedFor;
|
||||
|
||||
public AttachmentEncoding(String encoder, String encodedFor) {
|
||||
this.encoder = encoder;
|
||||
this.encodedFor = encodedFor;
|
||||
}
|
||||
|
||||
public String getEncoder() {
|
||||
return encoder;
|
||||
}
|
||||
|
||||
public String getEncodedFor() {
|
||||
return encodedFor;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,21 @@
|
||||
package im.rosetta.packet.runtime;
|
||||
|
||||
public class AttachmentTransport {
|
||||
|
||||
private String transportTag;
|
||||
private String transportServer;
|
||||
|
||||
public AttachmentTransport(String transportTag, String transportServer) {
|
||||
this.transportTag = transportTag;
|
||||
this.transportServer = transportServer;
|
||||
}
|
||||
|
||||
public String getTransportTag() {
|
||||
return transportTag;
|
||||
}
|
||||
|
||||
public String getTransportServer() {
|
||||
return transportServer;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user