Начало трансляции сервероного кода к новому протоколу
This commit is contained in:
@@ -4,7 +4,7 @@ import im.rosetta.calls.CallManager;
|
||||
import im.rosetta.client.ClientManager;
|
||||
import im.rosetta.client.OnlineManager;
|
||||
import im.rosetta.event.EventManager;
|
||||
import im.rosetta.executors.Executor0Handshake;
|
||||
import im.rosetta.executors.ExecutorHandshake;
|
||||
import im.rosetta.executors.Executor10RequestUpdate;
|
||||
import im.rosetta.executors.Executor11Typeing;
|
||||
import im.rosetta.executors.Executor15RequestTransport;
|
||||
@@ -12,7 +12,7 @@ import im.rosetta.executors.Executor16PushNotification;
|
||||
import im.rosetta.executors.Executor17GroupCreate;
|
||||
import im.rosetta.executors.Executor18GroupInfo;
|
||||
import im.rosetta.executors.Executor19GroupInviteInfo;
|
||||
import im.rosetta.executors.Executor1UserInfo;
|
||||
import im.rosetta.executors.ExecutorUserInfo;
|
||||
import im.rosetta.executors.Executor20GroupJoin;
|
||||
import im.rosetta.executors.Executor21GroupLeave;
|
||||
import im.rosetta.executors.Executor22GroupBan;
|
||||
@@ -33,32 +33,7 @@ import im.rosetta.listeners.ServerStopListener;
|
||||
import im.rosetta.logger.Logger;
|
||||
import im.rosetta.logger.enums.Color;
|
||||
import im.rosetta.logger.enums.LogLevel;
|
||||
import im.rosetta.packet.Packet0Handshake;
|
||||
import im.rosetta.packet.Packet10RequestUpdate;
|
||||
import im.rosetta.packet.Packet11Typeing;
|
||||
import im.rosetta.packet.Packet15RequestTransport;
|
||||
import im.rosetta.packet.Packet16PushNotification;
|
||||
import im.rosetta.packet.Packet17GroupCreate;
|
||||
import im.rosetta.packet.Packet18GroupInfo;
|
||||
import im.rosetta.packet.Packet19GroupInviteInfo;
|
||||
import im.rosetta.packet.Packet1UserInfo;
|
||||
import im.rosetta.packet.Packet20GroupJoin;
|
||||
import im.rosetta.packet.Packet21GroupLeave;
|
||||
import im.rosetta.packet.Packet22GroupBan;
|
||||
import im.rosetta.packet.Packet23DeviceList;
|
||||
import im.rosetta.packet.Packet24DeviceResolve;
|
||||
import im.rosetta.packet.Packet25Sync;
|
||||
import im.rosetta.packet.Packet26SignalPeer;
|
||||
import im.rosetta.packet.Packet27WebRTC;
|
||||
import im.rosetta.packet.Packet28IceServers;
|
||||
import im.rosetta.packet.Packet2Result;
|
||||
import im.rosetta.packet.Packet3Search;
|
||||
import im.rosetta.packet.Packet4OnlineSubscribe;
|
||||
import im.rosetta.packet.Packet5OnlineState;
|
||||
import im.rosetta.packet.Packet6Message;
|
||||
import im.rosetta.packet.Packet7Read;
|
||||
import im.rosetta.packet.Packet8Delivery;
|
||||
import im.rosetta.packet.Packet9DeviceNew;
|
||||
import im.rosetta.network.RccGeneratedPacketRegistry;
|
||||
import im.rosetta.service.services.BufferCleanupService;
|
||||
import im.rosetta.service.services.ForwardUnitService;
|
||||
import io.orprotocol.Server;
|
||||
@@ -158,7 +133,7 @@ public class Boot {
|
||||
public Boot bootstrap() {
|
||||
try{
|
||||
this.server.start();
|
||||
this.registerAllPackets();
|
||||
RccGeneratedPacketRegistry.registerAll(this.packetManager);
|
||||
this.registerAllExecutors();
|
||||
this.registerAllEvents();
|
||||
this.printBootMessage();
|
||||
@@ -180,41 +155,9 @@ public class Boot {
|
||||
this.eventManager.registerListener(new DeviceListListener(this.clientManager));
|
||||
}
|
||||
|
||||
private void registerAllPackets() {
|
||||
this.packetManager.registerPacket(0, Packet0Handshake.class);
|
||||
this.packetManager.registerPacket(1, Packet1UserInfo.class);
|
||||
this.packetManager.registerPacket(2, Packet2Result.class);
|
||||
this.packetManager.registerPacket(3, Packet3Search.class);
|
||||
this.packetManager.registerPacket(4, Packet4OnlineSubscribe.class);
|
||||
this.packetManager.registerPacket(5, Packet5OnlineState.class);
|
||||
this.packetManager.registerPacket(6, Packet6Message.class);
|
||||
this.packetManager.registerPacket(7, Packet7Read.class);
|
||||
this.packetManager.registerPacket(8, Packet8Delivery.class);
|
||||
this.packetManager.registerPacket(9, Packet9DeviceNew.class);
|
||||
this.packetManager.registerPacket(10, Packet10RequestUpdate.class);
|
||||
this.packetManager.registerPacket(11, Packet11Typeing.class);
|
||||
//RESERVED 12 PACKET AVATAR (unused)
|
||||
//RESERVED 13 PACKET KERNEL UPDATE (unused)
|
||||
//RESERVED 14 PACKET APP UPDATE (unused)
|
||||
this.packetManager.registerPacket(15, Packet15RequestTransport.class);
|
||||
this.packetManager.registerPacket(16, Packet16PushNotification.class);
|
||||
this.packetManager.registerPacket(17, Packet17GroupCreate.class);
|
||||
this.packetManager.registerPacket(18, Packet18GroupInfo.class);
|
||||
this.packetManager.registerPacket(19, Packet19GroupInviteInfo.class);
|
||||
this.packetManager.registerPacket(20, Packet20GroupJoin.class);
|
||||
this.packetManager.registerPacket(21, Packet21GroupLeave.class);
|
||||
this.packetManager.registerPacket(22, Packet22GroupBan.class);
|
||||
this.packetManager.registerPacket(23, Packet23DeviceList.class);
|
||||
this.packetManager.registerPacket(24, Packet24DeviceResolve.class);
|
||||
this.packetManager.registerPacket(25, Packet25Sync.class);
|
||||
this.packetManager.registerPacket(26, Packet26SignalPeer.class);
|
||||
this.packetManager.registerPacket(27, Packet27WebRTC.class);
|
||||
this.packetManager.registerPacket(28, Packet28IceServers.class);
|
||||
}
|
||||
|
||||
private void registerAllExecutors() {
|
||||
this.packetManager.registerExecutor(0, new Executor0Handshake(this.eventManager, this.clientManager, this.packetManager));
|
||||
this.packetManager.registerExecutor(1, new Executor1UserInfo());
|
||||
this.packetManager.registerExecutor(0, new ExecutorHandshake(this.eventManager, this.clientManager, this.packetManager));
|
||||
this.packetManager.registerExecutor(1, new ExecutorUserInfo());
|
||||
this.packetManager.registerExecutor(3, new Executor3Search(this.clientManager));
|
||||
this.packetManager.registerExecutor(4, new Executor4OnlineState(this.onlineManager, this.clientManager));
|
||||
this.packetManager.registerExecutor(6, new Executor6Message(this.clientManager, this.packetManager));
|
||||
|
||||
@@ -3,8 +3,7 @@ package im.rosetta.client.tags;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import im.rosetta.packet.runtime.HandshakeStage;
|
||||
|
||||
import im.rosetta.network.enums.HandshakeStage;
|
||||
import io.orprotocol.client.ECITag;
|
||||
|
||||
/**
|
||||
|
||||
@@ -13,9 +13,9 @@ import im.rosetta.event.EventManager;
|
||||
import im.rosetta.event.events.handshake.HandshakeCompletedEvent;
|
||||
import im.rosetta.event.events.handshake.HandshakeDeviceConfirmEvent;
|
||||
import im.rosetta.event.events.handshake.HandshakeFailedEvent;
|
||||
import im.rosetta.packet.Packet0Handshake;
|
||||
import im.rosetta.packet.Packet9DeviceNew;
|
||||
import im.rosetta.packet.runtime.HandshakeStage;
|
||||
import im.rosetta.network.enums.HandshakeStage;
|
||||
import im.rosetta.network.packet.PacketDeviceNew;
|
||||
import im.rosetta.network.packet.PacketHandshake;
|
||||
import im.rosetta.service.services.BufferService;
|
||||
import im.rosetta.service.services.DeviceService;
|
||||
|
||||
@@ -25,7 +25,7 @@ import io.orprotocol.lock.Lock;
|
||||
import io.orprotocol.packet.PacketExecutor;
|
||||
import io.orprotocol.packet.PacketManager;
|
||||
|
||||
public class Executor0Handshake extends PacketExecutor<Packet0Handshake> {
|
||||
public class ExecutorHandshake extends PacketExecutor<PacketHandshake> {
|
||||
|
||||
private final UserRepository userRepository = new UserRepository();
|
||||
private final DeviceRepository deviceRepository = new DeviceRepository();
|
||||
@@ -35,7 +35,7 @@ public class Executor0Handshake extends PacketExecutor<Packet0Handshake> {
|
||||
private final BufferRepository bufferRepository = new BufferRepository();
|
||||
private final BufferService bufferService;
|
||||
|
||||
public Executor0Handshake(EventManager eventManager, ClientManager clientManager, PacketManager packetManager) {
|
||||
public ExecutorHandshake(EventManager eventManager, ClientManager clientManager, PacketManager packetManager) {
|
||||
this.eventManager = eventManager;
|
||||
this.clientManager = clientManager;
|
||||
this.bufferService = new BufferService(bufferRepository, packetManager);
|
||||
@@ -43,7 +43,7 @@ public class Executor0Handshake extends PacketExecutor<Packet0Handshake> {
|
||||
|
||||
@Override
|
||||
@Lock(lockFor = "publicKey")
|
||||
public void onPacketReceived(Packet0Handshake handshake, Client client) throws ProtocolException {
|
||||
public void onPacketReceived(PacketHandshake handshake, Client client) throws ProtocolException {
|
||||
String publicKey = handshake.getPublicKey();
|
||||
String privateKey = handshake.getPrivateKey();
|
||||
String deviceId = handshake.getDeviceId();
|
||||
@@ -180,7 +180,7 @@ public class Executor0Handshake extends PacketExecutor<Packet0Handshake> {
|
||||
/**
|
||||
* Уведомляем все авторизованные устройства пользователя о том, что нужно подтвердить новое устройство
|
||||
*/
|
||||
Packet9DeviceNew newDevicePacket = new Packet9DeviceNew();
|
||||
PacketDeviceNew newDevicePacket = new PacketDeviceNew();
|
||||
newDevicePacket.setDeviceId(deviceId);
|
||||
newDevicePacket.setDeviceName(deviceName);
|
||||
newDevicePacket.setDeviceOs(deviceOs);
|
||||
@@ -9,16 +9,16 @@ import im.rosetta.Failures;
|
||||
import im.rosetta.client.tags.ECIAuthentificate;
|
||||
import im.rosetta.database.entity.User;
|
||||
import im.rosetta.database.repository.UserRepository;
|
||||
import im.rosetta.packet.Packet1UserInfo;
|
||||
import im.rosetta.packet.Packet2Result;
|
||||
import im.rosetta.packet.runtime.ResultCode;
|
||||
import im.rosetta.network.enums.ResultCode;
|
||||
import im.rosetta.network.packet.PacketResult;
|
||||
import im.rosetta.network.packet.PacketUserInfo;
|
||||
import im.rosetta.service.services.UserService;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.client.Client;
|
||||
import io.orprotocol.packet.PacketExecutor;
|
||||
|
||||
public class Executor1UserInfo extends PacketExecutor<Packet1UserInfo> {
|
||||
public class ExecutorUserInfo extends PacketExecutor<PacketUserInfo> {
|
||||
|
||||
private final UserRepository userRepository = new UserRepository();
|
||||
private final UserService userService = new UserService(userRepository);
|
||||
@@ -32,11 +32,12 @@ public class Executor1UserInfo extends PacketExecutor<Packet1UserInfo> {
|
||||
"deleted",
|
||||
"safety",
|
||||
"secure",
|
||||
"rosettasafe"
|
||||
"rosettasafe",
|
||||
"rosettadev1"
|
||||
));
|
||||
|
||||
@Override
|
||||
public void onPacketReceived(Packet1UserInfo packet, Client client) throws Exception, ProtocolException {
|
||||
public void onPacketReceived(PacketUserInfo packet, Client client) throws Exception, ProtocolException {
|
||||
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
|
||||
String username = packet.getUsername();
|
||||
String title = packet.getTitle();
|
||||
@@ -64,7 +65,7 @@ public class Executor1UserInfo extends PacketExecutor<Packet1UserInfo> {
|
||||
/**
|
||||
* Это имя пользователя уже занято, отправляем клиенту ошибку
|
||||
*/
|
||||
Packet2Result result = new Packet2Result();
|
||||
PacketResult result = new PacketResult();
|
||||
result.setResultCode(ResultCode.USERNAME_TAKEN);
|
||||
client.send(result);
|
||||
return;
|
||||
@@ -73,7 +74,7 @@ public class Executor1UserInfo extends PacketExecutor<Packet1UserInfo> {
|
||||
/**
|
||||
* Не удалось сменить username, отправляем клиенту ошибку
|
||||
*/
|
||||
Packet2Result result = new Packet2Result();
|
||||
PacketResult result = new PacketResult();
|
||||
result.setResultCode(ResultCode.INVALID);
|
||||
client.send(result);
|
||||
return;
|
||||
@@ -84,7 +85,7 @@ public class Executor1UserInfo extends PacketExecutor<Packet1UserInfo> {
|
||||
/**
|
||||
* Не удалось сменить title, отправляем клиенту ошибку
|
||||
*/
|
||||
Packet2Result result = new Packet2Result();
|
||||
PacketResult result = new PacketResult();
|
||||
result.setResultCode(ResultCode.INVALID);
|
||||
client.send(result);
|
||||
return;
|
||||
@@ -93,7 +94,7 @@ public class Executor1UserInfo extends PacketExecutor<Packet1UserInfo> {
|
||||
/**
|
||||
* Отправляем клиенту успешный результат
|
||||
*/
|
||||
Packet2Result result = new Packet2Result();
|
||||
PacketResult result = new PacketResult();
|
||||
result.setResultCode(ResultCode.SUCCESS);
|
||||
client.send(result);
|
||||
}
|
||||
116
src/main/java/im/rosetta/network/RccGeneratedPacketRegistry.java
Normal file
116
src/main/java/im/rosetta/network/RccGeneratedPacketRegistry.java
Normal file
@@ -0,0 +1,116 @@
|
||||
package im.rosetta.network;
|
||||
|
||||
import im.rosetta.network.packet.PacketHandshake;
|
||||
import im.rosetta.network.packet.PacketUserInfo;
|
||||
import im.rosetta.network.packet.PacketResult;
|
||||
import im.rosetta.network.packet.PacketSearch;
|
||||
import im.rosetta.network.packet.PacketOnlineSubscribe;
|
||||
import im.rosetta.network.packet.PacketOnlineState;
|
||||
import im.rosetta.network.packet.PacketMessage;
|
||||
import im.rosetta.network.packet.PacketRead;
|
||||
import im.rosetta.network.packet.PacketDelivery;
|
||||
import im.rosetta.network.packet.PacketDeviceNew;
|
||||
import im.rosetta.network.packet.PacketRequestUpdate;
|
||||
import im.rosetta.network.packet.PacketTypeing;
|
||||
import im.rosetta.network.packet.PacketRequestTransport;
|
||||
import im.rosetta.network.packet.PacketPushNotification;
|
||||
import im.rosetta.network.packet.PacketGroupCreate;
|
||||
import im.rosetta.network.packet.PacketGroupInfo;
|
||||
import im.rosetta.network.packet.PacketGroupInviteInfo;
|
||||
import im.rosetta.network.packet.PacketGroupJoin;
|
||||
import im.rosetta.network.packet.PacketGroupLeave;
|
||||
import im.rosetta.network.packet.PacketGroupBan;
|
||||
import im.rosetta.network.packet.PacketDeviceList;
|
||||
import im.rosetta.network.packet.PacketDeviceResolve;
|
||||
import im.rosetta.network.packet.PacketSync;
|
||||
import im.rosetta.network.packet.PacketSignalPeer;
|
||||
import im.rosetta.network.packet.PacketWebRTC;
|
||||
import im.rosetta.network.packet.PacketIceServers;
|
||||
import io.orprotocol.packet.PacketManager;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public final class RccGeneratedPacketRegistry {
|
||||
public static final int PACKET_HANDSHAKE_ID = 0;
|
||||
public static final int PACKET_USER_INFO_ID = 1;
|
||||
public static final int PACKET_RESULT_ID = 2;
|
||||
public static final int PACKET_SEARCH_ID = 3;
|
||||
public static final int PACKET_ONLINE_SUBSCRIBE_ID = 4;
|
||||
public static final int PACKET_ONLINE_STATE_ID = 5;
|
||||
public static final int PACKET_MESSAGE_ID = 6;
|
||||
public static final int PACKET_READ_ID = 7;
|
||||
public static final int PACKET_DELIVERY_ID = 8;
|
||||
public static final int PACKET_DEVICE_NEW_ID = 9;
|
||||
public static final int PACKET_REQUEST_UPDATE_ID = 10;
|
||||
public static final int PACKET_TYPEING_ID = 11;
|
||||
public static final int PACKET_REQUEST_TRANSPORT_ID = 15;
|
||||
public static final int PACKET_PUSH_NOTIFICATION_ID = 16;
|
||||
public static final int PACKET_GROUP_CREATE_ID = 17;
|
||||
public static final int PACKET_GROUP_INFO_ID = 18;
|
||||
public static final int PACKET_GROUP_INVITE_INFO_ID = 19;
|
||||
public static final int PACKET_GROUP_JOIN_ID = 20;
|
||||
public static final int PACKET_GROUP_LEAVE_ID = 21;
|
||||
public static final int PACKET_GROUP_BAN_ID = 22;
|
||||
public static final int PACKET_DEVICE_LIST_ID = 23;
|
||||
public static final int PACKET_DEVICE_RESOLVE_ID = 24;
|
||||
public static final int PACKET_SYNC_ID = 25;
|
||||
public static final int PACKET_SIGNAL_PEER_ID = 26;
|
||||
public static final int PACKET_WEB_RTC_ID = 27;
|
||||
public static final int PACKET_ICE_SERVERS_ID = 28;
|
||||
|
||||
private RccGeneratedPacketRegistry() {}
|
||||
|
||||
public static void registerAll(PacketManager manager) {
|
||||
manager.registerPacket(PACKET_HANDSHAKE_ID, PacketHandshake.class);
|
||||
manager.registerCodec(PACKET_HANDSHAKE_ID, new im.rosetta.network.codec.PacketHandshakeCodec());
|
||||
manager.registerPacket(PACKET_USER_INFO_ID, PacketUserInfo.class);
|
||||
manager.registerCodec(PACKET_USER_INFO_ID, new im.rosetta.network.codec.PacketUserInfoCodec());
|
||||
manager.registerPacket(PACKET_RESULT_ID, PacketResult.class);
|
||||
manager.registerCodec(PACKET_RESULT_ID, new im.rosetta.network.codec.PacketResultCodec());
|
||||
manager.registerPacket(PACKET_SEARCH_ID, PacketSearch.class);
|
||||
manager.registerCodec(PACKET_SEARCH_ID, new im.rosetta.network.codec.PacketSearchCodec());
|
||||
manager.registerPacket(PACKET_ONLINE_SUBSCRIBE_ID, PacketOnlineSubscribe.class);
|
||||
manager.registerCodec(PACKET_ONLINE_SUBSCRIBE_ID, new im.rosetta.network.codec.PacketOnlineSubscribeCodec());
|
||||
manager.registerPacket(PACKET_ONLINE_STATE_ID, PacketOnlineState.class);
|
||||
manager.registerCodec(PACKET_ONLINE_STATE_ID, new im.rosetta.network.codec.PacketOnlineStateCodec());
|
||||
manager.registerPacket(PACKET_MESSAGE_ID, PacketMessage.class);
|
||||
manager.registerCodec(PACKET_MESSAGE_ID, new im.rosetta.network.codec.PacketMessageCodec());
|
||||
manager.registerPacket(PACKET_READ_ID, PacketRead.class);
|
||||
manager.registerCodec(PACKET_READ_ID, new im.rosetta.network.codec.PacketReadCodec());
|
||||
manager.registerPacket(PACKET_DELIVERY_ID, PacketDelivery.class);
|
||||
manager.registerCodec(PACKET_DELIVERY_ID, new im.rosetta.network.codec.PacketDeliveryCodec());
|
||||
manager.registerPacket(PACKET_DEVICE_NEW_ID, PacketDeviceNew.class);
|
||||
manager.registerCodec(PACKET_DEVICE_NEW_ID, new im.rosetta.network.codec.PacketDeviceNewCodec());
|
||||
manager.registerPacket(PACKET_REQUEST_UPDATE_ID, PacketRequestUpdate.class);
|
||||
manager.registerCodec(PACKET_REQUEST_UPDATE_ID, new im.rosetta.network.codec.PacketRequestUpdateCodec());
|
||||
manager.registerPacket(PACKET_TYPEING_ID, PacketTypeing.class);
|
||||
manager.registerCodec(PACKET_TYPEING_ID, new im.rosetta.network.codec.PacketTypeingCodec());
|
||||
manager.registerPacket(PACKET_REQUEST_TRANSPORT_ID, PacketRequestTransport.class);
|
||||
manager.registerCodec(PACKET_REQUEST_TRANSPORT_ID, new im.rosetta.network.codec.PacketRequestTransportCodec());
|
||||
manager.registerPacket(PACKET_PUSH_NOTIFICATION_ID, PacketPushNotification.class);
|
||||
manager.registerCodec(PACKET_PUSH_NOTIFICATION_ID, new im.rosetta.network.codec.PacketPushNotificationCodec());
|
||||
manager.registerPacket(PACKET_GROUP_CREATE_ID, PacketGroupCreate.class);
|
||||
manager.registerCodec(PACKET_GROUP_CREATE_ID, new im.rosetta.network.codec.PacketGroupCreateCodec());
|
||||
manager.registerPacket(PACKET_GROUP_INFO_ID, PacketGroupInfo.class);
|
||||
manager.registerCodec(PACKET_GROUP_INFO_ID, new im.rosetta.network.codec.PacketGroupInfoCodec());
|
||||
manager.registerPacket(PACKET_GROUP_INVITE_INFO_ID, PacketGroupInviteInfo.class);
|
||||
manager.registerCodec(PACKET_GROUP_INVITE_INFO_ID, new im.rosetta.network.codec.PacketGroupInviteInfoCodec());
|
||||
manager.registerPacket(PACKET_GROUP_JOIN_ID, PacketGroupJoin.class);
|
||||
manager.registerCodec(PACKET_GROUP_JOIN_ID, new im.rosetta.network.codec.PacketGroupJoinCodec());
|
||||
manager.registerPacket(PACKET_GROUP_LEAVE_ID, PacketGroupLeave.class);
|
||||
manager.registerCodec(PACKET_GROUP_LEAVE_ID, new im.rosetta.network.codec.PacketGroupLeaveCodec());
|
||||
manager.registerPacket(PACKET_GROUP_BAN_ID, PacketGroupBan.class);
|
||||
manager.registerCodec(PACKET_GROUP_BAN_ID, new im.rosetta.network.codec.PacketGroupBanCodec());
|
||||
manager.registerPacket(PACKET_DEVICE_LIST_ID, PacketDeviceList.class);
|
||||
manager.registerCodec(PACKET_DEVICE_LIST_ID, new im.rosetta.network.codec.PacketDeviceListCodec());
|
||||
manager.registerPacket(PACKET_DEVICE_RESOLVE_ID, PacketDeviceResolve.class);
|
||||
manager.registerCodec(PACKET_DEVICE_RESOLVE_ID, new im.rosetta.network.codec.PacketDeviceResolveCodec());
|
||||
manager.registerPacket(PACKET_SYNC_ID, PacketSync.class);
|
||||
manager.registerCodec(PACKET_SYNC_ID, new im.rosetta.network.codec.PacketSyncCodec());
|
||||
manager.registerPacket(PACKET_SIGNAL_PEER_ID, PacketSignalPeer.class);
|
||||
manager.registerCodec(PACKET_SIGNAL_PEER_ID, new im.rosetta.network.codec.PacketSignalPeerCodec());
|
||||
manager.registerPacket(PACKET_WEB_RTC_ID, PacketWebRTC.class);
|
||||
manager.registerCodec(PACKET_WEB_RTC_ID, new im.rosetta.network.codec.PacketWebRTCCodec());
|
||||
manager.registerPacket(PACKET_ICE_SERVERS_ID, PacketIceServers.class);
|
||||
manager.registerCodec(PACKET_ICE_SERVERS_ID, new im.rosetta.network.codec.PacketIceServersCodec());
|
||||
}
|
||||
}
|
||||
90
src/main/java/im/rosetta/network/codec/AttachmentCodec.java
Normal file
90
src/main/java/im/rosetta/network/codec/AttachmentCodec.java
Normal file
@@ -0,0 +1,90 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.types.Attachment;
|
||||
import im.rosetta.network.enums.AttachmentType;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public final class AttachmentCodec {
|
||||
private static final int F_ID = 1;
|
||||
private static final int F_BLOB = 2;
|
||||
private static final int F_TYPE = 3;
|
||||
private static final int F_PREVIEW = 4;
|
||||
private static final int F_TRANSPORT = 5;
|
||||
|
||||
private AttachmentCodec() {}
|
||||
|
||||
public static Attachment decode(byte[] raw, int version) throws ProtocolException {
|
||||
if (raw == null) {
|
||||
return null;
|
||||
}
|
||||
TlvReader reader = new TlvReader(raw);
|
||||
Attachment model = new Attachment();
|
||||
if (version >= 1) {
|
||||
model.id = reader.getString(F_ID);
|
||||
}
|
||||
if (version >= 1) {
|
||||
model.blob = reader.getString(F_BLOB);
|
||||
}
|
||||
if (version >= 1) {
|
||||
model.type = AttachmentType.fromCode(reader.getInt32(F_TYPE), version);
|
||||
}
|
||||
if (version >= 1) {
|
||||
model.preview = reader.getString(F_PREVIEW);
|
||||
}
|
||||
if (version >= 1) {
|
||||
model.transport = AttachmentTransportCodec.decode(reader.getBytes(F_TRANSPORT), version);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
public static byte[] encode(Attachment model, int version) throws ProtocolException {
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (model.id != null) writer.writeString(F_ID, model.id);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (model.blob != null) writer.writeString(F_BLOB, model.blob);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (model.type != null) { model.type.requireSupportedInVersion(version); writer.writeInt32(F_TYPE, model.type.getCode()); }
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (model.preview != null) writer.writeString(F_PREVIEW, model.preview);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (model.transport != null) writer.writeBytes(F_TRANSPORT, AttachmentTransportCodec.encode(model.transport, version));
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
public static List<Attachment> decodeList(List<byte[]> raws, int version) throws ProtocolException {
|
||||
List<Attachment> out = new ArrayList<>();
|
||||
if (raws == null) {
|
||||
return out;
|
||||
}
|
||||
for (byte[] raw : raws) {
|
||||
out.add(decode(raw, version));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public static List<byte[]> encodeList(List<Attachment> values, int version) throws ProtocolException {
|
||||
List<byte[]> out = new ArrayList<>();
|
||||
if (values == null) {
|
||||
return out;
|
||||
}
|
||||
for (Attachment value : values) {
|
||||
out.add(encode(value, version));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.types.AttachmentTransport;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public final class AttachmentTransportCodec {
|
||||
private static final int F_TRANSPORT_TAG = 1;
|
||||
private static final int F_TRANSPORT_SERVER = 2;
|
||||
|
||||
private AttachmentTransportCodec() {}
|
||||
|
||||
public static AttachmentTransport decode(byte[] raw, int version) throws ProtocolException {
|
||||
if (raw == null) {
|
||||
return null;
|
||||
}
|
||||
TlvReader reader = new TlvReader(raw);
|
||||
AttachmentTransport model = new AttachmentTransport();
|
||||
if (version >= 1) {
|
||||
model.transportTag = reader.getString(F_TRANSPORT_TAG);
|
||||
}
|
||||
if (version >= 1) {
|
||||
model.transportServer = reader.getString(F_TRANSPORT_SERVER);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
public static byte[] encode(AttachmentTransport model, int version) throws ProtocolException {
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (model.transportTag != null) writer.writeString(F_TRANSPORT_TAG, model.transportTag);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (model.transportServer != null) writer.writeString(F_TRANSPORT_SERVER, model.transportServer);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
public static List<AttachmentTransport> decodeList(List<byte[]> raws, int version) throws ProtocolException {
|
||||
List<AttachmentTransport> out = new ArrayList<>();
|
||||
if (raws == null) {
|
||||
return out;
|
||||
}
|
||||
for (byte[] raw : raws) {
|
||||
out.add(decode(raw, version));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public static List<byte[]> encodeList(List<AttachmentTransport> values, int version) throws ProtocolException {
|
||||
List<byte[]> out = new ArrayList<>();
|
||||
if (values == null) {
|
||||
return out;
|
||||
}
|
||||
for (AttachmentTransport value : values) {
|
||||
out.add(encode(value, version));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,91 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.types.NetworkDevice;
|
||||
import im.rosetta.network.enums.DeviceSolution;
|
||||
import im.rosetta.network.enums.NetworkStatus;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public final class NetworkDeviceCodec {
|
||||
private static final int F_NETWORK_STATUS = 1;
|
||||
private static final int F_DEVICE_NAME = 2;
|
||||
private static final int F_DEVICE_OS = 3;
|
||||
private static final int F_DEVICE_ID = 4;
|
||||
private static final int F_DEVICE_SOLUTION = 5;
|
||||
|
||||
private NetworkDeviceCodec() {}
|
||||
|
||||
public static NetworkDevice decode(byte[] raw, int version) throws ProtocolException {
|
||||
if (raw == null) {
|
||||
return null;
|
||||
}
|
||||
TlvReader reader = new TlvReader(raw);
|
||||
NetworkDevice model = new NetworkDevice();
|
||||
if (version >= 1) {
|
||||
model.networkStatus = NetworkStatus.fromCode(reader.getInt32(F_NETWORK_STATUS), version);
|
||||
}
|
||||
if (version >= 1) {
|
||||
model.deviceName = reader.getString(F_DEVICE_NAME);
|
||||
}
|
||||
if (version >= 1) {
|
||||
model.deviceOs = reader.getString(F_DEVICE_OS);
|
||||
}
|
||||
if (version >= 1) {
|
||||
model.deviceId = reader.getString(F_DEVICE_ID);
|
||||
}
|
||||
if (version >= 1) {
|
||||
model.deviceSolution = DeviceSolution.fromCode(reader.getInt32(F_DEVICE_SOLUTION), version);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
public static byte[] encode(NetworkDevice model, int version) throws ProtocolException {
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (model.networkStatus != null) { model.networkStatus.requireSupportedInVersion(version); writer.writeInt32(F_NETWORK_STATUS, model.networkStatus.getCode()); }
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (model.deviceName != null) writer.writeString(F_DEVICE_NAME, model.deviceName);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (model.deviceOs != null) writer.writeString(F_DEVICE_OS, model.deviceOs);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (model.deviceId != null) writer.writeString(F_DEVICE_ID, model.deviceId);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (model.deviceSolution != null) { model.deviceSolution.requireSupportedInVersion(version); writer.writeInt32(F_DEVICE_SOLUTION, model.deviceSolution.getCode()); }
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
public static List<NetworkDevice> decodeList(List<byte[]> raws, int version) throws ProtocolException {
|
||||
List<NetworkDevice> out = new ArrayList<>();
|
||||
if (raws == null) {
|
||||
return out;
|
||||
}
|
||||
for (byte[] raw : raws) {
|
||||
out.add(decode(raw, version));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public static List<byte[]> encodeList(List<NetworkDevice> values, int version) throws ProtocolException {
|
||||
List<byte[]> out = new ArrayList<>();
|
||||
if (values == null) {
|
||||
return out;
|
||||
}
|
||||
for (NetworkDevice value : values) {
|
||||
out.add(encode(value, version));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.types.PKNetworkStatus;
|
||||
import im.rosetta.network.enums.NetworkStatus;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public final class PKNetworkStatusCodec {
|
||||
private static final int F_PUBLIC_KEY = 1;
|
||||
private static final int F_NETWORK_STATUS = 2;
|
||||
|
||||
private PKNetworkStatusCodec() {}
|
||||
|
||||
public static PKNetworkStatus decode(byte[] raw, int version) throws ProtocolException {
|
||||
if (raw == null) {
|
||||
return null;
|
||||
}
|
||||
TlvReader reader = new TlvReader(raw);
|
||||
PKNetworkStatus model = new PKNetworkStatus();
|
||||
if (version >= 1) {
|
||||
model.publicKey = reader.getString(F_PUBLIC_KEY);
|
||||
}
|
||||
if (version >= 1) {
|
||||
model.networkStatus = NetworkStatus.fromCode(reader.getInt32(F_NETWORK_STATUS), version);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
public static byte[] encode(PKNetworkStatus model, int version) throws ProtocolException {
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (model.publicKey != null) writer.writeString(F_PUBLIC_KEY, model.publicKey);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (model.networkStatus != null) { model.networkStatus.requireSupportedInVersion(version); writer.writeInt32(F_NETWORK_STATUS, model.networkStatus.getCode()); }
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
public static List<PKNetworkStatus> decodeList(List<byte[]> raws, int version) throws ProtocolException {
|
||||
List<PKNetworkStatus> out = new ArrayList<>();
|
||||
if (raws == null) {
|
||||
return out;
|
||||
}
|
||||
for (byte[] raw : raws) {
|
||||
out.add(decode(raw, version));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public static List<byte[]> encodeList(List<PKNetworkStatus> values, int version) throws ProtocolException {
|
||||
List<byte[]> out = new ArrayList<>();
|
||||
if (values == null) {
|
||||
return out;
|
||||
}
|
||||
for (PKNetworkStatus value : values) {
|
||||
out.add(encode(value, version));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketDelivery;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketDeliveryCodec implements Codec<PacketDelivery> {
|
||||
private static final int F_MESSAGE_ID = 1;
|
||||
private static final int F_TO_PUBLIC_KEY = 2;
|
||||
|
||||
@Override
|
||||
public PacketDelivery decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketDelivery packet = new PacketDelivery();
|
||||
if (version >= 1) {
|
||||
packet.messageId = reader.getString(F_MESSAGE_ID);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.toPublicKey = reader.getString(F_TO_PUBLIC_KEY);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketDelivery packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.messageId != null) writer.writeString(F_MESSAGE_ID, packet.messageId);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.toPublicKey != null) writer.writeString(F_TO_PUBLIC_KEY, packet.toPublicKey);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketDeviceList;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketDeviceListCodec implements Codec<PacketDeviceList> {
|
||||
private static final int F_DEVICES = 1;
|
||||
|
||||
@Override
|
||||
public PacketDeviceList decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketDeviceList packet = new PacketDeviceList();
|
||||
if (version >= 1) {
|
||||
packet.devices = NetworkDeviceCodec.decodeList(reader.getBytesList(F_DEVICES), version);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketDeviceList packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.devices != null) writer.writeBytesList(F_DEVICES, NetworkDeviceCodec.encodeList(packet.devices, version));
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,54 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketDeviceNew;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketDeviceNewCodec implements Codec<PacketDeviceNew> {
|
||||
private static final int F_IP_ADDRESS = 1;
|
||||
private static final int F_DEVICE_ID = 2;
|
||||
private static final int F_DEVICE_NAME = 3;
|
||||
private static final int F_DEVICE_OS = 4;
|
||||
|
||||
@Override
|
||||
public PacketDeviceNew decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketDeviceNew packet = new PacketDeviceNew();
|
||||
if (version >= 1) {
|
||||
packet.ipAddress = reader.getString(F_IP_ADDRESS);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.deviceId = reader.getString(F_DEVICE_ID);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.deviceName = reader.getString(F_DEVICE_NAME);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.deviceOs = reader.getString(F_DEVICE_OS);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketDeviceNew packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.ipAddress != null) writer.writeString(F_IP_ADDRESS, packet.ipAddress);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.deviceId != null) writer.writeString(F_DEVICE_ID, packet.deviceId);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.deviceName != null) writer.writeString(F_DEVICE_NAME, packet.deviceName);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.deviceOs != null) writer.writeString(F_DEVICE_OS, packet.deviceOs);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketDeviceResolve;
|
||||
import im.rosetta.network.enums.DeviceSolution;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketDeviceResolveCodec implements Codec<PacketDeviceResolve> {
|
||||
private static final int F_DEVICE_ID = 1;
|
||||
private static final int F_SOLUTION = 2;
|
||||
|
||||
@Override
|
||||
public PacketDeviceResolve decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketDeviceResolve packet = new PacketDeviceResolve();
|
||||
if (version >= 1) {
|
||||
packet.deviceId = reader.getString(F_DEVICE_ID);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.solution = DeviceSolution.fromCode(reader.getInt32(F_SOLUTION), version);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketDeviceResolve packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.deviceId != null) writer.writeString(F_DEVICE_ID, packet.deviceId);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.solution != null) { packet.solution.requireSupportedInVersion(version); writer.writeInt32(F_SOLUTION, packet.solution.getCode()); }
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketGroupBan;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketGroupBanCodec implements Codec<PacketGroupBan> {
|
||||
private static final int F_GROUP_ID = 1;
|
||||
private static final int F_PUBLIC_KEY = 2;
|
||||
|
||||
@Override
|
||||
public PacketGroupBan decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketGroupBan packet = new PacketGroupBan();
|
||||
if (version >= 1) {
|
||||
packet.groupId = reader.getString(F_GROUP_ID);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.publicKey = reader.getString(F_PUBLIC_KEY);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketGroupBan packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.groupId != null) writer.writeString(F_GROUP_ID, packet.groupId);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.publicKey != null) writer.writeString(F_PUBLIC_KEY, packet.publicKey);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketGroupCreate;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketGroupCreateCodec implements Codec<PacketGroupCreate> {
|
||||
private static final int F_GROUP_ID = 1;
|
||||
|
||||
@Override
|
||||
public PacketGroupCreate decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketGroupCreate packet = new PacketGroupCreate();
|
||||
if (version >= 1) {
|
||||
packet.groupId = reader.getString(F_GROUP_ID);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketGroupCreate packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.groupId != null) writer.writeString(F_GROUP_ID, packet.groupId);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketGroupInfo;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketGroupInfoCodec implements Codec<PacketGroupInfo> {
|
||||
private static final int F_GROUP_ID = 1;
|
||||
private static final int F_MEMBERS_PKS = 2;
|
||||
|
||||
@Override
|
||||
public PacketGroupInfo decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketGroupInfo packet = new PacketGroupInfo();
|
||||
if (version >= 1) {
|
||||
packet.groupId = reader.getString(F_GROUP_ID);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.membersPKs = reader.getStringList(F_MEMBERS_PKS);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketGroupInfo packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.groupId != null) writer.writeString(F_GROUP_ID, packet.groupId);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.membersPKs != null) writer.writeStringList(F_MEMBERS_PKS, packet.membersPKs);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketGroupInviteInfo;
|
||||
import im.rosetta.network.enums.GroupStatus;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketGroupInviteInfoCodec implements Codec<PacketGroupInviteInfo> {
|
||||
private static final int F_GROUP_ID = 1;
|
||||
private static final int F_MEMBERS_COUNT = 2;
|
||||
private static final int F_STATUS = 3;
|
||||
|
||||
@Override
|
||||
public PacketGroupInviteInfo decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketGroupInviteInfo packet = new PacketGroupInviteInfo();
|
||||
if (version >= 1) {
|
||||
packet.groupId = reader.getString(F_GROUP_ID);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.membersCount = reader.getInt32(F_MEMBERS_COUNT);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.status = GroupStatus.fromCode(reader.getInt32(F_STATUS), version);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketGroupInviteInfo packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.groupId != null) writer.writeString(F_GROUP_ID, packet.groupId);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.membersCount != null) writer.writeInt32(F_MEMBERS_COUNT, packet.membersCount);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.status != null) { packet.status.requireSupportedInVersion(version); writer.writeInt32(F_STATUS, packet.status.getCode()); }
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,48 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketGroupJoin;
|
||||
import im.rosetta.network.enums.GroupStatus;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketGroupJoinCodec implements Codec<PacketGroupJoin> {
|
||||
private static final int F_GROUP_ID = 1;
|
||||
private static final int F_STATUS = 2;
|
||||
private static final int F_GROUP_STRING = 3;
|
||||
|
||||
@Override
|
||||
public PacketGroupJoin decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketGroupJoin packet = new PacketGroupJoin();
|
||||
if (version >= 1) {
|
||||
packet.groupId = reader.getString(F_GROUP_ID);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.status = GroupStatus.fromCode(reader.getInt32(F_STATUS), version);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.groupString = reader.getString(F_GROUP_STRING);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketGroupJoin packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.groupId != null) writer.writeString(F_GROUP_ID, packet.groupId);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.status != null) { packet.status.requireSupportedInVersion(version); writer.writeInt32(F_STATUS, packet.status.getCode()); }
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.groupString != null) writer.writeString(F_GROUP_STRING, packet.groupString);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketGroupLeave;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketGroupLeaveCodec implements Codec<PacketGroupLeave> {
|
||||
private static final int F_GROUP_ID = 1;
|
||||
|
||||
@Override
|
||||
public PacketGroupLeave decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketGroupLeave packet = new PacketGroupLeave();
|
||||
if (version >= 1) {
|
||||
packet.groupId = reader.getString(F_GROUP_ID);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketGroupLeave packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.groupId != null) writer.writeString(F_GROUP_ID, packet.groupId);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,83 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketHandshake;
|
||||
import im.rosetta.network.enums.HandshakeStage;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketHandshakeCodec implements Codec<PacketHandshake> {
|
||||
private static final int F_PUBLIC_KEY = 1;
|
||||
private static final int F_PRIVATE_KEY = 2;
|
||||
private static final int F_PROTOCOL_VERSION = 3;
|
||||
private static final int F_HEARTBEAT_INTERVAL = 4;
|
||||
private static final int F_DEVICE_ID = 5;
|
||||
private static final int F_DEVICE_NAME = 6;
|
||||
private static final int F_DEVICE_OS = 7;
|
||||
private static final int F_HANDSHAKE_STAGE = 8;
|
||||
|
||||
@Override
|
||||
public PacketHandshake decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketHandshake packet = new PacketHandshake();
|
||||
if (version >= 1) {
|
||||
packet.publicKey = reader.getString(F_PUBLIC_KEY);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.privateKey = reader.getString(F_PRIVATE_KEY);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.protocolVersion = reader.getInt32(F_PROTOCOL_VERSION);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.heartbeatInterval = reader.getInt32(F_HEARTBEAT_INTERVAL);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.deviceId = reader.getString(F_DEVICE_ID);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.deviceName = reader.getString(F_DEVICE_NAME);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.deviceOs = reader.getString(F_DEVICE_OS);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.handshakeStage = HandshakeStage.fromCode(reader.getInt32(F_HANDSHAKE_STAGE), version);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketHandshake packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.publicKey != null) writer.writeString(F_PUBLIC_KEY, packet.publicKey);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.privateKey != null) writer.writeString(F_PRIVATE_KEY, packet.privateKey);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.protocolVersion != null) writer.writeInt32(F_PROTOCOL_VERSION, packet.protocolVersion);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.heartbeatInterval != null) writer.writeInt32(F_HEARTBEAT_INTERVAL, packet.heartbeatInterval);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.deviceId != null) writer.writeString(F_DEVICE_ID, packet.deviceId);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.deviceName != null) writer.writeString(F_DEVICE_NAME, packet.deviceName);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.deviceOs != null) writer.writeString(F_DEVICE_OS, packet.deviceOs);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.handshakeStage != null) { packet.handshakeStage.requireSupportedInVersion(version); writer.writeInt32(F_HANDSHAKE_STAGE, packet.handshakeStage.getCode()); }
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketIceServers;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketIceServersCodec implements Codec<PacketIceServers> {
|
||||
private static final int F_ICE_SERVERS = 1;
|
||||
|
||||
@Override
|
||||
public PacketIceServers decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketIceServers packet = new PacketIceServers();
|
||||
if (version >= 1) {
|
||||
packet.iceServers = RTCIceServerCodec.decodeList(reader.getBytesList(F_ICE_SERVERS), version);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketIceServers packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.iceServers != null) writer.writeBytesList(F_ICE_SERVERS, RTCIceServerCodec.encodeList(packet.iceServers, version));
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,89 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketMessage;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketMessageCodec implements Codec<PacketMessage> {
|
||||
private static final int F_FROM_PUBLIC_KEY = 1;
|
||||
private static final int F_TO_PUBLIC_KEY = 2;
|
||||
private static final int F_PRIVATE_KEY = 3;
|
||||
private static final int F_CONTENT = 4;
|
||||
private static final int F_CHACHA_KEY = 5;
|
||||
private static final int F_TIMESTAMP = 6;
|
||||
private static final int F_MESSAGE_ID = 7;
|
||||
private static final int F_ATTACHMENTS = 8;
|
||||
private static final int F_AES_CHACHA_KEY = 9;
|
||||
|
||||
@Override
|
||||
public PacketMessage decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketMessage packet = new PacketMessage();
|
||||
if (version >= 1) {
|
||||
packet.fromPublicKey = reader.getString(F_FROM_PUBLIC_KEY);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.toPublicKey = reader.getString(F_TO_PUBLIC_KEY);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.privateKey = reader.getString(F_PRIVATE_KEY);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.content = reader.getString(F_CONTENT);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.chachaKey = reader.getString(F_CHACHA_KEY);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.timestamp = reader.getInt64(F_TIMESTAMP);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.messageId = reader.getString(F_MESSAGE_ID);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.attachments = AttachmentCodec.decodeList(reader.getBytesList(F_ATTACHMENTS), version);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.aesChachaKey = reader.getString(F_AES_CHACHA_KEY);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketMessage packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.fromPublicKey != null) writer.writeString(F_FROM_PUBLIC_KEY, packet.fromPublicKey);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.toPublicKey != null) writer.writeString(F_TO_PUBLIC_KEY, packet.toPublicKey);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.privateKey != null) writer.writeString(F_PRIVATE_KEY, packet.privateKey);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.content != null) writer.writeString(F_CONTENT, packet.content);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.chachaKey != null) writer.writeString(F_CHACHA_KEY, packet.chachaKey);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.timestamp != null) writer.writeInt64(F_TIMESTAMP, packet.timestamp);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.messageId != null) writer.writeString(F_MESSAGE_ID, packet.messageId);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.attachments != null) writer.writeBytesList(F_ATTACHMENTS, AttachmentCodec.encodeList(packet.attachments, version));
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.aesChachaKey != null) writer.writeString(F_AES_CHACHA_KEY, packet.aesChachaKey);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketOnlineState;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketOnlineStateCodec implements Codec<PacketOnlineState> {
|
||||
private static final int F_PK_NETWORK_STATUSES = 1;
|
||||
|
||||
@Override
|
||||
public PacketOnlineState decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketOnlineState packet = new PacketOnlineState();
|
||||
if (version >= 1) {
|
||||
packet.pkNetworkStatuses = PKNetworkStatusCodec.decodeList(reader.getBytesList(F_PK_NETWORK_STATUSES), version);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketOnlineState packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.pkNetworkStatuses != null) writer.writeBytesList(F_PK_NETWORK_STATUSES, PKNetworkStatusCodec.encodeList(packet.pkNetworkStatuses, version));
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketOnlineSubscribe;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketOnlineSubscribeCodec implements Codec<PacketOnlineSubscribe> {
|
||||
private static final int F_PRIVATE_KEY = 1;
|
||||
private static final int F_PUBLIC_KEYS = 2;
|
||||
|
||||
@Override
|
||||
public PacketOnlineSubscribe decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketOnlineSubscribe packet = new PacketOnlineSubscribe();
|
||||
if (version >= 1) {
|
||||
packet.privateKey = reader.getString(F_PRIVATE_KEY);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.publicKeys = reader.getStringList(F_PUBLIC_KEYS);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketOnlineSubscribe packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.privateKey != null) writer.writeString(F_PRIVATE_KEY, packet.privateKey);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.publicKeys != null) writer.writeStringList(F_PUBLIC_KEYS, packet.publicKeys);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,56 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketPushNotification;
|
||||
import im.rosetta.network.enums.NotificationAction;
|
||||
import im.rosetta.network.enums.TokenType;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketPushNotificationCodec implements Codec<PacketPushNotification> {
|
||||
private static final int F_NOTIFICATION_TOKEN = 1;
|
||||
private static final int F_ACTION = 2;
|
||||
private static final int F_TOKEN_TYPE = 3;
|
||||
private static final int F_DEVICE_ID = 4;
|
||||
|
||||
@Override
|
||||
public PacketPushNotification decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketPushNotification packet = new PacketPushNotification();
|
||||
if (version >= 1) {
|
||||
packet.notificationToken = reader.getString(F_NOTIFICATION_TOKEN);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.action = NotificationAction.fromCode(reader.getInt32(F_ACTION), version);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.tokenType = TokenType.fromCode(reader.getInt32(F_TOKEN_TYPE), version);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.deviceId = reader.getString(F_DEVICE_ID);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketPushNotification packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.notificationToken != null) writer.writeString(F_NOTIFICATION_TOKEN, packet.notificationToken);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.action != null) { packet.action.requireSupportedInVersion(version); writer.writeInt32(F_ACTION, packet.action.getCode()); }
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.tokenType != null) { packet.tokenType.requireSupportedInVersion(version); writer.writeInt32(F_TOKEN_TYPE, packet.tokenType.getCode()); }
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.deviceId != null) writer.writeString(F_DEVICE_ID, packet.deviceId);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
47
src/main/java/im/rosetta/network/codec/PacketReadCodec.java
Normal file
47
src/main/java/im/rosetta/network/codec/PacketReadCodec.java
Normal file
@@ -0,0 +1,47 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketRead;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketReadCodec implements Codec<PacketRead> {
|
||||
private static final int F_FROM_PUBLIC_KEY = 1;
|
||||
private static final int F_TO_PUBLIC_KEY = 2;
|
||||
private static final int F_PRIVATE_KEY = 3;
|
||||
|
||||
@Override
|
||||
public PacketRead decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketRead packet = new PacketRead();
|
||||
if (version >= 1) {
|
||||
packet.fromPublicKey = reader.getString(F_FROM_PUBLIC_KEY);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.toPublicKey = reader.getString(F_TO_PUBLIC_KEY);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.privateKey = reader.getString(F_PRIVATE_KEY);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketRead packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.fromPublicKey != null) writer.writeString(F_FROM_PUBLIC_KEY, packet.fromPublicKey);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.toPublicKey != null) writer.writeString(F_TO_PUBLIC_KEY, packet.toPublicKey);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.privateKey != null) writer.writeString(F_PRIVATE_KEY, packet.privateKey);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketRequestTransport;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketRequestTransportCodec implements Codec<PacketRequestTransport> {
|
||||
private static final int F_SERVER = 1;
|
||||
|
||||
@Override
|
||||
public PacketRequestTransport decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketRequestTransport packet = new PacketRequestTransport();
|
||||
if (version >= 1) {
|
||||
packet.server = reader.getString(F_SERVER);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketRequestTransport packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.server != null) writer.writeString(F_SERVER, packet.server);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,33 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketRequestUpdate;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketRequestUpdateCodec implements Codec<PacketRequestUpdate> {
|
||||
private static final int F_SERVER = 1;
|
||||
|
||||
@Override
|
||||
public PacketRequestUpdate decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketRequestUpdate packet = new PacketRequestUpdate();
|
||||
if (version >= 1) {
|
||||
packet.server = reader.getString(F_SERVER);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketRequestUpdate packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.server != null) writer.writeString(F_SERVER, packet.server);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,34 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketResult;
|
||||
import im.rosetta.network.enums.ResultCode;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketResultCodec implements Codec<PacketResult> {
|
||||
private static final int F_RESULT_CODE = 1;
|
||||
|
||||
@Override
|
||||
public PacketResult decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketResult packet = new PacketResult();
|
||||
if (version >= 1) {
|
||||
packet.resultCode = ResultCode.fromCode(reader.getInt32(F_RESULT_CODE), version);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketResult packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.resultCode != null) { packet.resultCode.requireSupportedInVersion(version); writer.writeInt32(F_RESULT_CODE, packet.resultCode.getCode()); }
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketSearch;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketSearchCodec implements Codec<PacketSearch> {
|
||||
private static final int F_PRIVATE_KEY = 1;
|
||||
private static final int F_SEARCH = 2;
|
||||
private static final int F_SEARCH_INFO = 3;
|
||||
|
||||
@Override
|
||||
public PacketSearch decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketSearch packet = new PacketSearch();
|
||||
if (version >= 1) {
|
||||
packet.privateKey = reader.getString(F_PRIVATE_KEY);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.search = reader.getString(F_SEARCH);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.searchInfo = SearchInfoCodec.decodeList(reader.getBytesList(F_SEARCH_INFO), version);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketSearch packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.privateKey != null) writer.writeString(F_PRIVATE_KEY, packet.privateKey);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.search != null) writer.writeString(F_SEARCH, packet.search);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.searchInfo != null) writer.writeBytesList(F_SEARCH_INFO, SearchInfoCodec.encodeList(packet.searchInfo, version));
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,69 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketSignalPeer;
|
||||
import im.rosetta.network.enums.SignalType;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketSignalPeerCodec implements Codec<PacketSignalPeer> {
|
||||
private static final int F_SRC = 1;
|
||||
private static final int F_DST = 2;
|
||||
private static final int F_SHARED_PUBLIC = 3;
|
||||
private static final int F_SIGNAL_TYPE = 4;
|
||||
private static final int F_CALL_ID = 5;
|
||||
private static final int F_JOIN_TOKEN = 6;
|
||||
|
||||
@Override
|
||||
public PacketSignalPeer decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketSignalPeer packet = new PacketSignalPeer();
|
||||
if (version >= 1) {
|
||||
packet.src = reader.getString(F_SRC);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.dst = reader.getString(F_DST);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.sharedPublic = reader.getString(F_SHARED_PUBLIC);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.signalType = SignalType.fromCode(reader.getInt32(F_SIGNAL_TYPE), version);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.callId = reader.getString(F_CALL_ID);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.joinToken = reader.getString(F_JOIN_TOKEN);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketSignalPeer packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.src != null) writer.writeString(F_SRC, packet.src);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.dst != null) writer.writeString(F_DST, packet.dst);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.sharedPublic != null) writer.writeString(F_SHARED_PUBLIC, packet.sharedPublic);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.signalType != null) { packet.signalType.requireSupportedInVersion(version); writer.writeInt32(F_SIGNAL_TYPE, packet.signalType.getCode()); }
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.callId != null) writer.writeString(F_CALL_ID, packet.callId);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.joinToken != null) writer.writeString(F_JOIN_TOKEN, packet.joinToken);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
41
src/main/java/im/rosetta/network/codec/PacketSyncCodec.java
Normal file
41
src/main/java/im/rosetta/network/codec/PacketSyncCodec.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketSync;
|
||||
import im.rosetta.network.enums.SyncStatus;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketSyncCodec implements Codec<PacketSync> {
|
||||
private static final int F_SYNC_STATUS = 1;
|
||||
private static final int F_TIMESTAMP = 2;
|
||||
|
||||
@Override
|
||||
public PacketSync decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketSync packet = new PacketSync();
|
||||
if (version >= 1) {
|
||||
packet.syncStatus = SyncStatus.fromCode(reader.getInt32(F_SYNC_STATUS), version);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.timestamp = reader.getInt64(F_TIMESTAMP);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketSync packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.syncStatus != null) { packet.syncStatus.requireSupportedInVersion(version); writer.writeInt32(F_SYNC_STATUS, packet.syncStatus.getCode()); }
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.timestamp != null) writer.writeInt64(F_TIMESTAMP, packet.timestamp);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketTypeing;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketTypeingCodec implements Codec<PacketTypeing> {
|
||||
private static final int F_FROM_PUBLIC_KEY = 1;
|
||||
private static final int F_TO_PUBLIC_KEY = 2;
|
||||
private static final int F_PRIVATE_KEY = 3;
|
||||
|
||||
@Override
|
||||
public PacketTypeing decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketTypeing packet = new PacketTypeing();
|
||||
if (version >= 1) {
|
||||
packet.fromPublicKey = reader.getString(F_FROM_PUBLIC_KEY);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.toPublicKey = reader.getString(F_TO_PUBLIC_KEY);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.privateKey = reader.getString(F_PRIVATE_KEY);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketTypeing packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.fromPublicKey != null) writer.writeString(F_FROM_PUBLIC_KEY, packet.fromPublicKey);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.toPublicKey != null) writer.writeString(F_TO_PUBLIC_KEY, packet.toPublicKey);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.privateKey != null) writer.writeString(F_PRIVATE_KEY, packet.privateKey);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,47 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketUserInfo;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketUserInfoCodec implements Codec<PacketUserInfo> {
|
||||
private static final int F_PRIVATE_KEY = 1;
|
||||
private static final int F_USERNAME = 2;
|
||||
private static final int F_TITLE = 3;
|
||||
|
||||
@Override
|
||||
public PacketUserInfo decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketUserInfo packet = new PacketUserInfo();
|
||||
if (version >= 1) {
|
||||
packet.privateKey = reader.getString(F_PRIVATE_KEY);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.username = reader.getString(F_USERNAME);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.title = reader.getString(F_TITLE);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketUserInfo packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.privateKey != null) writer.writeString(F_PRIVATE_KEY, packet.privateKey);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.username != null) writer.writeString(F_USERNAME, packet.username);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.title != null) writer.writeString(F_TITLE, packet.title);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.buffer.Buffer;
|
||||
import io.orprotocol.codec.Codec;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.packet.PacketWebRTC;
|
||||
import im.rosetta.network.enums.WebRTCType;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class PacketWebRTCCodec implements Codec<PacketWebRTC> {
|
||||
private static final int F_SDP_OR_CANDIDATE = 1;
|
||||
private static final int F_TYPE = 2;
|
||||
|
||||
@Override
|
||||
public PacketWebRTC decode(Buffer data, int version) throws ProtocolException {
|
||||
byte[] payload = data.readBytes(data.remaining());
|
||||
TlvReader reader = new TlvReader(payload);
|
||||
PacketWebRTC packet = new PacketWebRTC();
|
||||
if (version >= 1) {
|
||||
packet.sdpOrCandidate = reader.getString(F_SDP_OR_CANDIDATE);
|
||||
}
|
||||
if (version >= 1) {
|
||||
packet.type = WebRTCType.fromCode(reader.getInt32(F_TYPE), version);
|
||||
}
|
||||
return packet;
|
||||
}
|
||||
|
||||
@Override
|
||||
public byte[] encode(PacketWebRTC packet, int version) throws ProtocolException {
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (packet.sdpOrCandidate != null) writer.writeString(F_SDP_OR_CANDIDATE, packet.sdpOrCandidate);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (packet.type != null) { packet.type.requireSupportedInVersion(version); writer.writeInt32(F_TYPE, packet.type.getCode()); }
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,82 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.types.RTCIceServer;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public final class RTCIceServerCodec {
|
||||
private static final int F_URL = 1;
|
||||
private static final int F_USERNAME = 2;
|
||||
private static final int F_CREDENTIAL = 3;
|
||||
private static final int F_TRANSPORT = 4;
|
||||
|
||||
private RTCIceServerCodec() {}
|
||||
|
||||
public static RTCIceServer decode(byte[] raw, int version) throws ProtocolException {
|
||||
if (raw == null) {
|
||||
return null;
|
||||
}
|
||||
TlvReader reader = new TlvReader(raw);
|
||||
RTCIceServer model = new RTCIceServer();
|
||||
if (version >= 1) {
|
||||
model.url = reader.getString(F_URL);
|
||||
}
|
||||
if (version >= 1) {
|
||||
model.username = reader.getString(F_USERNAME);
|
||||
}
|
||||
if (version >= 1) {
|
||||
model.credential = reader.getString(F_CREDENTIAL);
|
||||
}
|
||||
if (version >= 1) {
|
||||
model.transport = reader.getString(F_TRANSPORT);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
public static byte[] encode(RTCIceServer model, int version) throws ProtocolException {
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (model.url != null) writer.writeString(F_URL, model.url);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (model.username != null) writer.writeString(F_USERNAME, model.username);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (model.credential != null) writer.writeString(F_CREDENTIAL, model.credential);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (model.transport != null) writer.writeString(F_TRANSPORT, model.transport);
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
public static List<RTCIceServer> decodeList(List<byte[]> raws, int version) throws ProtocolException {
|
||||
List<RTCIceServer> out = new ArrayList<>();
|
||||
if (raws == null) {
|
||||
return out;
|
||||
}
|
||||
for (byte[] raw : raws) {
|
||||
out.add(decode(raw, version));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public static List<byte[]> encodeList(List<RTCIceServer> values, int version) throws ProtocolException {
|
||||
List<byte[]> out = new ArrayList<>();
|
||||
if (values == null) {
|
||||
return out;
|
||||
}
|
||||
for (RTCIceServer value : values) {
|
||||
out.add(encode(value, version));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
90
src/main/java/im/rosetta/network/codec/SearchInfoCodec.java
Normal file
90
src/main/java/im/rosetta/network/codec/SearchInfoCodec.java
Normal file
@@ -0,0 +1,90 @@
|
||||
package im.rosetta.network.codec;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.orprotocol.ProtocolException;
|
||||
import io.orprotocol.tlv.read.TlvReader;
|
||||
import io.orprotocol.tlv.write.TlvWriter;
|
||||
import im.rosetta.network.types.SearchInfo;
|
||||
import im.rosetta.network.enums.NetworkStatus;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public final class SearchInfoCodec {
|
||||
private static final int F_USERNAME = 1;
|
||||
private static final int F_TITLE = 2;
|
||||
private static final int F_PUBLIC_KEY = 3;
|
||||
private static final int F_VERIFIED = 4;
|
||||
private static final int F_NETWORK_STATUS = 5;
|
||||
|
||||
private SearchInfoCodec() {}
|
||||
|
||||
public static SearchInfo decode(byte[] raw, int version) throws ProtocolException {
|
||||
if (raw == null) {
|
||||
return null;
|
||||
}
|
||||
TlvReader reader = new TlvReader(raw);
|
||||
SearchInfo model = new SearchInfo();
|
||||
if (version >= 1) {
|
||||
model.username = reader.getString(F_USERNAME);
|
||||
}
|
||||
if (version >= 1) {
|
||||
model.title = reader.getString(F_TITLE);
|
||||
}
|
||||
if (version >= 1) {
|
||||
model.publicKey = reader.getString(F_PUBLIC_KEY);
|
||||
}
|
||||
if (version >= 1) {
|
||||
model.verified = reader.getInt32(F_VERIFIED);
|
||||
}
|
||||
if (version >= 1) {
|
||||
model.networkStatus = NetworkStatus.fromCode(reader.getInt32(F_NETWORK_STATUS), version);
|
||||
}
|
||||
return model;
|
||||
}
|
||||
|
||||
public static byte[] encode(SearchInfo model, int version) throws ProtocolException {
|
||||
if (model == null) {
|
||||
return null;
|
||||
}
|
||||
TlvWriter writer = new TlvWriter();
|
||||
if (version >= 1) {
|
||||
if (model.username != null) writer.writeString(F_USERNAME, model.username);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (model.title != null) writer.writeString(F_TITLE, model.title);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (model.publicKey != null) writer.writeString(F_PUBLIC_KEY, model.publicKey);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (model.verified != null) writer.writeInt32(F_VERIFIED, model.verified);
|
||||
}
|
||||
if (version >= 1) {
|
||||
if (model.networkStatus != null) { model.networkStatus.requireSupportedInVersion(version); writer.writeInt32(F_NETWORK_STATUS, model.networkStatus.getCode()); }
|
||||
}
|
||||
return writer.toByteArray();
|
||||
}
|
||||
|
||||
public static List<SearchInfo> decodeList(List<byte[]> raws, int version) throws ProtocolException {
|
||||
List<SearchInfo> out = new ArrayList<>();
|
||||
if (raws == null) {
|
||||
return out;
|
||||
}
|
||||
for (byte[] raw : raws) {
|
||||
out.add(decode(raw, version));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
|
||||
public static List<byte[]> encodeList(List<SearchInfo> values, int version) throws ProtocolException {
|
||||
List<byte[]> out = new ArrayList<>();
|
||||
if (values == null) {
|
||||
return out;
|
||||
}
|
||||
for (SearchInfo value : values) {
|
||||
out.add(encode(value, version));
|
||||
}
|
||||
return out;
|
||||
}
|
||||
}
|
||||
61
src/main/java/im/rosetta/network/enums/AttachmentType.java
Normal file
61
src/main/java/im/rosetta/network/enums/AttachmentType.java
Normal file
@@ -0,0 +1,61 @@
|
||||
package im.rosetta.network.enums;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public enum AttachmentType {
|
||||
IMAGE(0),
|
||||
MESSAGES(1),
|
||||
FILE(2),
|
||||
AVATAR(3),
|
||||
CALL(4),
|
||||
VOICE(5),
|
||||
VIDEO_CIRCLE(6);
|
||||
|
||||
private final Integer code;
|
||||
|
||||
AttachmentType(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static AttachmentType fromCode(int code) {
|
||||
return switch (code) {
|
||||
case 0 -> IMAGE;
|
||||
case 1 -> MESSAGES;
|
||||
case 2 -> FILE;
|
||||
case 3 -> AVATAR;
|
||||
case 4 -> CALL;
|
||||
case 5 -> VOICE;
|
||||
case 6 -> VIDEO_CIRCLE;
|
||||
default -> throw new IllegalArgumentException("Unknown AttachmentType code: " + code);
|
||||
};
|
||||
}
|
||||
|
||||
public static AttachmentType fromCode(int code, int version) {
|
||||
AttachmentType value = fromCode(code);
|
||||
if (!value.isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported AttachmentType code " + code + " for version " + version);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isSupportedInVersion(int version) {
|
||||
return switch (this) {
|
||||
case IMAGE -> true;
|
||||
case MESSAGES -> true;
|
||||
case FILE -> true;
|
||||
case AVATAR -> true;
|
||||
case CALL -> true;
|
||||
case VOICE -> true;
|
||||
case VIDEO_CIRCLE -> true;
|
||||
};
|
||||
}
|
||||
|
||||
public void requireSupportedInVersion(int version) {
|
||||
if (!isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported AttachmentType value " + this + " for version " + version);
|
||||
}
|
||||
}
|
||||
}
|
||||
46
src/main/java/im/rosetta/network/enums/DeviceSolution.java
Normal file
46
src/main/java/im/rosetta/network/enums/DeviceSolution.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package im.rosetta.network.enums;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public enum DeviceSolution {
|
||||
ACCEPT(0),
|
||||
DECLINE(1);
|
||||
|
||||
private final Integer code;
|
||||
|
||||
DeviceSolution(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static DeviceSolution fromCode(int code) {
|
||||
return switch (code) {
|
||||
case 0 -> ACCEPT;
|
||||
case 1 -> DECLINE;
|
||||
default -> throw new IllegalArgumentException("Unknown DeviceSolution code: " + code);
|
||||
};
|
||||
}
|
||||
|
||||
public static DeviceSolution fromCode(int code, int version) {
|
||||
DeviceSolution value = fromCode(code);
|
||||
if (!value.isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported DeviceSolution code " + code + " for version " + version);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isSupportedInVersion(int version) {
|
||||
return switch (this) {
|
||||
case ACCEPT -> true;
|
||||
case DECLINE -> true;
|
||||
};
|
||||
}
|
||||
|
||||
public void requireSupportedInVersion(int version) {
|
||||
if (!isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported DeviceSolution value " + this + " for version " + version);
|
||||
}
|
||||
}
|
||||
}
|
||||
52
src/main/java/im/rosetta/network/enums/GroupStatus.java
Normal file
52
src/main/java/im/rosetta/network/enums/GroupStatus.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package im.rosetta.network.enums;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public enum GroupStatus {
|
||||
JOINED(0),
|
||||
INVALID(1),
|
||||
NOT_JOINED(2),
|
||||
BANNED(3);
|
||||
|
||||
private final Integer code;
|
||||
|
||||
GroupStatus(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static GroupStatus fromCode(int code) {
|
||||
return switch (code) {
|
||||
case 0 -> JOINED;
|
||||
case 1 -> INVALID;
|
||||
case 2 -> NOT_JOINED;
|
||||
case 3 -> BANNED;
|
||||
default -> throw new IllegalArgumentException("Unknown GroupStatus code: " + code);
|
||||
};
|
||||
}
|
||||
|
||||
public static GroupStatus fromCode(int code, int version) {
|
||||
GroupStatus value = fromCode(code);
|
||||
if (!value.isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported GroupStatus code " + code + " for version " + version);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isSupportedInVersion(int version) {
|
||||
return switch (this) {
|
||||
case JOINED -> true;
|
||||
case INVALID -> true;
|
||||
case NOT_JOINED -> true;
|
||||
case BANNED -> true;
|
||||
};
|
||||
}
|
||||
|
||||
public void requireSupportedInVersion(int version) {
|
||||
if (!isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported GroupStatus value " + this + " for version " + version);
|
||||
}
|
||||
}
|
||||
}
|
||||
46
src/main/java/im/rosetta/network/enums/HandshakeStage.java
Normal file
46
src/main/java/im/rosetta/network/enums/HandshakeStage.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package im.rosetta.network.enums;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public enum HandshakeStage {
|
||||
COMPLETED(0),
|
||||
NEED_DEVICE_VERIFICATION(1);
|
||||
|
||||
private final Integer code;
|
||||
|
||||
HandshakeStage(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static HandshakeStage fromCode(int code) {
|
||||
return switch (code) {
|
||||
case 0 -> COMPLETED;
|
||||
case 1 -> NEED_DEVICE_VERIFICATION;
|
||||
default -> throw new IllegalArgumentException("Unknown HandshakeStage code: " + code);
|
||||
};
|
||||
}
|
||||
|
||||
public static HandshakeStage fromCode(int code, int version) {
|
||||
HandshakeStage value = fromCode(code);
|
||||
if (!value.isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported HandshakeStage code " + code + " for version " + version);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isSupportedInVersion(int version) {
|
||||
return switch (this) {
|
||||
case COMPLETED -> true;
|
||||
case NEED_DEVICE_VERIFICATION -> true;
|
||||
};
|
||||
}
|
||||
|
||||
public void requireSupportedInVersion(int version) {
|
||||
if (!isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported HandshakeStage value " + this + " for version " + version);
|
||||
}
|
||||
}
|
||||
}
|
||||
46
src/main/java/im/rosetta/network/enums/NetworkStatus.java
Normal file
46
src/main/java/im/rosetta/network/enums/NetworkStatus.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package im.rosetta.network.enums;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public enum NetworkStatus {
|
||||
ONLINE(0),
|
||||
OFFLINE(1);
|
||||
|
||||
private final Integer code;
|
||||
|
||||
NetworkStatus(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static NetworkStatus fromCode(int code) {
|
||||
return switch (code) {
|
||||
case 0 -> ONLINE;
|
||||
case 1 -> OFFLINE;
|
||||
default -> throw new IllegalArgumentException("Unknown NetworkStatus code: " + code);
|
||||
};
|
||||
}
|
||||
|
||||
public static NetworkStatus fromCode(int code, int version) {
|
||||
NetworkStatus value = fromCode(code);
|
||||
if (!value.isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported NetworkStatus code " + code + " for version " + version);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isSupportedInVersion(int version) {
|
||||
return switch (this) {
|
||||
case ONLINE -> true;
|
||||
case OFFLINE -> true;
|
||||
};
|
||||
}
|
||||
|
||||
public void requireSupportedInVersion(int version) {
|
||||
if (!isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported NetworkStatus value " + this + " for version " + version);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,46 @@
|
||||
package im.rosetta.network.enums;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public enum NotificationAction {
|
||||
SUBSCRIBE(0),
|
||||
UNSUBSCRIBE(1);
|
||||
|
||||
private final Integer code;
|
||||
|
||||
NotificationAction(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static NotificationAction fromCode(int code) {
|
||||
return switch (code) {
|
||||
case 0 -> SUBSCRIBE;
|
||||
case 1 -> UNSUBSCRIBE;
|
||||
default -> throw new IllegalArgumentException("Unknown NotificationAction code: " + code);
|
||||
};
|
||||
}
|
||||
|
||||
public static NotificationAction fromCode(int code, int version) {
|
||||
NotificationAction value = fromCode(code);
|
||||
if (!value.isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported NotificationAction code " + code + " for version " + version);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isSupportedInVersion(int version) {
|
||||
return switch (this) {
|
||||
case SUBSCRIBE -> true;
|
||||
case UNSUBSCRIBE -> true;
|
||||
};
|
||||
}
|
||||
|
||||
public void requireSupportedInVersion(int version) {
|
||||
if (!isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported NotificationAction value " + this + " for version " + version);
|
||||
}
|
||||
}
|
||||
}
|
||||
52
src/main/java/im/rosetta/network/enums/ResultCode.java
Normal file
52
src/main/java/im/rosetta/network/enums/ResultCode.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package im.rosetta.network.enums;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public enum ResultCode {
|
||||
SUCCESS(0),
|
||||
ERROR(1),
|
||||
INVALID(2),
|
||||
USERNAME_TAKEN(3);
|
||||
|
||||
private final Integer code;
|
||||
|
||||
ResultCode(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static ResultCode fromCode(int code) {
|
||||
return switch (code) {
|
||||
case 0 -> SUCCESS;
|
||||
case 1 -> ERROR;
|
||||
case 2 -> INVALID;
|
||||
case 3 -> USERNAME_TAKEN;
|
||||
default -> throw new IllegalArgumentException("Unknown ResultCode code: " + code);
|
||||
};
|
||||
}
|
||||
|
||||
public static ResultCode fromCode(int code, int version) {
|
||||
ResultCode value = fromCode(code);
|
||||
if (!value.isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported ResultCode code " + code + " for version " + version);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isSupportedInVersion(int version) {
|
||||
return switch (this) {
|
||||
case SUCCESS -> true;
|
||||
case ERROR -> true;
|
||||
case INVALID -> true;
|
||||
case USERNAME_TAKEN -> true;
|
||||
};
|
||||
}
|
||||
|
||||
public void requireSupportedInVersion(int version) {
|
||||
if (!isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported ResultCode value " + this + " for version " + version);
|
||||
}
|
||||
}
|
||||
}
|
||||
67
src/main/java/im/rosetta/network/enums/SignalType.java
Normal file
67
src/main/java/im/rosetta/network/enums/SignalType.java
Normal file
@@ -0,0 +1,67 @@
|
||||
package im.rosetta.network.enums;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public enum SignalType {
|
||||
CALL(0),
|
||||
KEY_EXCHANGE(1),
|
||||
ACTIVE_CALL(2),
|
||||
END_CALL(3),
|
||||
ACTIVE(4),
|
||||
END_CALL_BECAUSE_PEER_DISCONNECTED(5),
|
||||
END_CALL_BECAUSE_BUSY(6),
|
||||
ACCEPT(7),
|
||||
RINGING_TIMEOUT(8);
|
||||
|
||||
private final Integer code;
|
||||
|
||||
SignalType(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static SignalType fromCode(int code) {
|
||||
return switch (code) {
|
||||
case 0 -> CALL;
|
||||
case 1 -> KEY_EXCHANGE;
|
||||
case 2 -> ACTIVE_CALL;
|
||||
case 3 -> END_CALL;
|
||||
case 4 -> ACTIVE;
|
||||
case 5 -> END_CALL_BECAUSE_PEER_DISCONNECTED;
|
||||
case 6 -> END_CALL_BECAUSE_BUSY;
|
||||
case 7 -> ACCEPT;
|
||||
case 8 -> RINGING_TIMEOUT;
|
||||
default -> throw new IllegalArgumentException("Unknown SignalType code: " + code);
|
||||
};
|
||||
}
|
||||
|
||||
public static SignalType fromCode(int code, int version) {
|
||||
SignalType value = fromCode(code);
|
||||
if (!value.isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported SignalType code " + code + " for version " + version);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isSupportedInVersion(int version) {
|
||||
return switch (this) {
|
||||
case CALL -> true;
|
||||
case KEY_EXCHANGE -> true;
|
||||
case ACTIVE_CALL -> true;
|
||||
case END_CALL -> true;
|
||||
case ACTIVE -> true;
|
||||
case END_CALL_BECAUSE_PEER_DISCONNECTED -> true;
|
||||
case END_CALL_BECAUSE_BUSY -> true;
|
||||
case ACCEPT -> true;
|
||||
case RINGING_TIMEOUT -> true;
|
||||
};
|
||||
}
|
||||
|
||||
public void requireSupportedInVersion(int version) {
|
||||
if (!isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported SignalType value " + this + " for version " + version);
|
||||
}
|
||||
}
|
||||
}
|
||||
49
src/main/java/im/rosetta/network/enums/SyncStatus.java
Normal file
49
src/main/java/im/rosetta/network/enums/SyncStatus.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package im.rosetta.network.enums;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public enum SyncStatus {
|
||||
NOT_NEEDED(0),
|
||||
BATCH_START(1),
|
||||
BATCH_END(2);
|
||||
|
||||
private final Integer code;
|
||||
|
||||
SyncStatus(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static SyncStatus fromCode(int code) {
|
||||
return switch (code) {
|
||||
case 0 -> NOT_NEEDED;
|
||||
case 1 -> BATCH_START;
|
||||
case 2 -> BATCH_END;
|
||||
default -> throw new IllegalArgumentException("Unknown SyncStatus code: " + code);
|
||||
};
|
||||
}
|
||||
|
||||
public static SyncStatus fromCode(int code, int version) {
|
||||
SyncStatus value = fromCode(code);
|
||||
if (!value.isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported SyncStatus code " + code + " for version " + version);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isSupportedInVersion(int version) {
|
||||
return switch (this) {
|
||||
case NOT_NEEDED -> true;
|
||||
case BATCH_START -> true;
|
||||
case BATCH_END -> true;
|
||||
};
|
||||
}
|
||||
|
||||
public void requireSupportedInVersion(int version) {
|
||||
if (!isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported SyncStatus value " + this + " for version " + version);
|
||||
}
|
||||
}
|
||||
}
|
||||
46
src/main/java/im/rosetta/network/enums/TokenType.java
Normal file
46
src/main/java/im/rosetta/network/enums/TokenType.java
Normal file
@@ -0,0 +1,46 @@
|
||||
package im.rosetta.network.enums;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public enum TokenType {
|
||||
FCM(0),
|
||||
VoIPApns(1);
|
||||
|
||||
private final Integer code;
|
||||
|
||||
TokenType(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static TokenType fromCode(int code) {
|
||||
return switch (code) {
|
||||
case 0 -> FCM;
|
||||
case 1 -> VoIPApns;
|
||||
default -> throw new IllegalArgumentException("Unknown TokenType code: " + code);
|
||||
};
|
||||
}
|
||||
|
||||
public static TokenType fromCode(int code, int version) {
|
||||
TokenType value = fromCode(code);
|
||||
if (!value.isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported TokenType code " + code + " for version " + version);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isSupportedInVersion(int version) {
|
||||
return switch (this) {
|
||||
case FCM -> true;
|
||||
case VoIPApns -> true;
|
||||
};
|
||||
}
|
||||
|
||||
public void requireSupportedInVersion(int version) {
|
||||
if (!isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported TokenType value " + this + " for version " + version);
|
||||
}
|
||||
}
|
||||
}
|
||||
49
src/main/java/im/rosetta/network/enums/WebRTCType.java
Normal file
49
src/main/java/im/rosetta/network/enums/WebRTCType.java
Normal file
@@ -0,0 +1,49 @@
|
||||
package im.rosetta.network.enums;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public enum WebRTCType {
|
||||
OFFER(0),
|
||||
ANSWER(1),
|
||||
ICE_CANDIDATE(2);
|
||||
|
||||
private final Integer code;
|
||||
|
||||
WebRTCType(Integer code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public Integer getCode() {
|
||||
return code;
|
||||
}
|
||||
|
||||
public static WebRTCType fromCode(int code) {
|
||||
return switch (code) {
|
||||
case 0 -> OFFER;
|
||||
case 1 -> ANSWER;
|
||||
case 2 -> ICE_CANDIDATE;
|
||||
default -> throw new IllegalArgumentException("Unknown WebRTCType code: " + code);
|
||||
};
|
||||
}
|
||||
|
||||
public static WebRTCType fromCode(int code, int version) {
|
||||
WebRTCType value = fromCode(code);
|
||||
if (!value.isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported WebRTCType code " + code + " for version " + version);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
public boolean isSupportedInVersion(int version) {
|
||||
return switch (this) {
|
||||
case OFFER -> true;
|
||||
case ANSWER -> true;
|
||||
case ICE_CANDIDATE -> true;
|
||||
};
|
||||
}
|
||||
|
||||
public void requireSupportedInVersion(int version) {
|
||||
if (!isSupportedInVersion(version)) {
|
||||
throw new IllegalArgumentException("Unsupported WebRTCType value " + this + " for version " + version);
|
||||
}
|
||||
}
|
||||
}
|
||||
24
src/main/java/im/rosetta/network/packet/PacketDelivery.java
Normal file
24
src/main/java/im/rosetta/network/packet/PacketDelivery.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
public class PacketDelivery extends Packet {
|
||||
public String messageId;
|
||||
public String toPublicKey;
|
||||
|
||||
public String getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public void setMessageId(String messageId) {
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
public String getToPublicKey() {
|
||||
return toPublicKey;
|
||||
}
|
||||
|
||||
public void setToPublicKey(String toPublicKey) {
|
||||
this.toPublicKey = toPublicKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
import im.rosetta.network.types.NetworkDevice;
|
||||
|
||||
public class PacketDeviceList extends Packet {
|
||||
public java.util.List<NetworkDevice> devices;
|
||||
|
||||
public java.util.List<NetworkDevice> getDevices() {
|
||||
return devices;
|
||||
}
|
||||
|
||||
public void setDevices(java.util.List<NetworkDevice> devices) {
|
||||
this.devices = devices;
|
||||
}
|
||||
}
|
||||
42
src/main/java/im/rosetta/network/packet/PacketDeviceNew.java
Normal file
42
src/main/java/im/rosetta/network/packet/PacketDeviceNew.java
Normal file
@@ -0,0 +1,42 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
public class PacketDeviceNew extends Packet {
|
||||
public String ipAddress;
|
||||
public String deviceId;
|
||||
public String deviceName;
|
||||
public String deviceOs;
|
||||
|
||||
public String getIpAddress() {
|
||||
return ipAddress;
|
||||
}
|
||||
|
||||
public void setIpAddress(String ipAddress) {
|
||||
this.ipAddress = ipAddress;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getDeviceName() {
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
public void setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
|
||||
public String getDeviceOs() {
|
||||
return deviceOs;
|
||||
}
|
||||
|
||||
public void setDeviceOs(String deviceOs) {
|
||||
this.deviceOs = deviceOs;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
import im.rosetta.network.enums.DeviceSolution;
|
||||
|
||||
public class PacketDeviceResolve extends Packet {
|
||||
public String deviceId;
|
||||
public DeviceSolution solution;
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public DeviceSolution getSolution() {
|
||||
return solution;
|
||||
}
|
||||
|
||||
public void setSolution(DeviceSolution solution) {
|
||||
this.solution = solution;
|
||||
}
|
||||
}
|
||||
24
src/main/java/im/rosetta/network/packet/PacketGroupBan.java
Normal file
24
src/main/java/im/rosetta/network/packet/PacketGroupBan.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
public class PacketGroupBan extends Packet {
|
||||
public String groupId;
|
||||
public String publicKey;
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public String getPublicKey() {
|
||||
return publicKey;
|
||||
}
|
||||
|
||||
public void setPublicKey(String publicKey) {
|
||||
this.publicKey = publicKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
public class PacketGroupCreate extends Packet {
|
||||
public String groupId;
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
}
|
||||
24
src/main/java/im/rosetta/network/packet/PacketGroupInfo.java
Normal file
24
src/main/java/im/rosetta/network/packet/PacketGroupInfo.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
public class PacketGroupInfo extends Packet {
|
||||
public String groupId;
|
||||
public java.util.List<String> membersPKs;
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public java.util.List<String> getMembersPKs() {
|
||||
return membersPKs;
|
||||
}
|
||||
|
||||
public void setMembersPKs(java.util.List<String> membersPKs) {
|
||||
this.membersPKs = membersPKs;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,35 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
import im.rosetta.network.enums.GroupStatus;
|
||||
|
||||
public class PacketGroupInviteInfo extends Packet {
|
||||
public String groupId;
|
||||
public Integer membersCount;
|
||||
public GroupStatus status;
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public Integer getMembersCount() {
|
||||
return membersCount;
|
||||
}
|
||||
|
||||
public void setMembersCount(Integer membersCount) {
|
||||
this.membersCount = membersCount;
|
||||
}
|
||||
|
||||
public GroupStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(GroupStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
}
|
||||
35
src/main/java/im/rosetta/network/packet/PacketGroupJoin.java
Normal file
35
src/main/java/im/rosetta/network/packet/PacketGroupJoin.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
import im.rosetta.network.enums.GroupStatus;
|
||||
|
||||
public class PacketGroupJoin extends Packet {
|
||||
public String groupId;
|
||||
public GroupStatus status;
|
||||
public String groupString;
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
public GroupStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
public void setStatus(GroupStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
public String getGroupString() {
|
||||
return groupString;
|
||||
}
|
||||
|
||||
public void setGroupString(String groupString) {
|
||||
this.groupString = groupString;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
public class PacketGroupLeave extends Packet {
|
||||
public String groupId;
|
||||
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
}
|
||||
80
src/main/java/im/rosetta/network/packet/PacketHandshake.java
Normal file
80
src/main/java/im/rosetta/network/packet/PacketHandshake.java
Normal file
@@ -0,0 +1,80 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
import im.rosetta.network.enums.HandshakeStage;
|
||||
|
||||
public class PacketHandshake extends Packet {
|
||||
public String publicKey;
|
||||
public String privateKey;
|
||||
public Integer protocolVersion;
|
||||
public Integer heartbeatInterval;
|
||||
public String deviceId;
|
||||
public String deviceName;
|
||||
public String deviceOs;
|
||||
public HandshakeStage handshakeStage;
|
||||
|
||||
public String getPublicKey() {
|
||||
return publicKey;
|
||||
}
|
||||
|
||||
public void setPublicKey(String publicKey) {
|
||||
this.publicKey = publicKey;
|
||||
}
|
||||
|
||||
public String getPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
public void setPrivateKey(String privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
public Integer getProtocolVersion() {
|
||||
return protocolVersion;
|
||||
}
|
||||
|
||||
public void setProtocolVersion(Integer protocolVersion) {
|
||||
this.protocolVersion = protocolVersion;
|
||||
}
|
||||
|
||||
public Integer getHeartbeatInterval() {
|
||||
return heartbeatInterval;
|
||||
}
|
||||
|
||||
public void setHeartbeatInterval(Integer heartbeatInterval) {
|
||||
this.heartbeatInterval = heartbeatInterval;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public String getDeviceName() {
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
public void setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
|
||||
public String getDeviceOs() {
|
||||
return deviceOs;
|
||||
}
|
||||
|
||||
public void setDeviceOs(String deviceOs) {
|
||||
this.deviceOs = deviceOs;
|
||||
}
|
||||
|
||||
public HandshakeStage getHandshakeStage() {
|
||||
return handshakeStage;
|
||||
}
|
||||
|
||||
public void setHandshakeStage(HandshakeStage handshakeStage) {
|
||||
this.handshakeStage = handshakeStage;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
import im.rosetta.network.types.RTCIceServer;
|
||||
|
||||
public class PacketIceServers extends Packet {
|
||||
public java.util.List<RTCIceServer> iceServers;
|
||||
|
||||
public java.util.List<RTCIceServer> getIceServers() {
|
||||
return iceServers;
|
||||
}
|
||||
|
||||
public void setIceServers(java.util.List<RTCIceServer> iceServers) {
|
||||
this.iceServers = iceServers;
|
||||
}
|
||||
}
|
||||
89
src/main/java/im/rosetta/network/packet/PacketMessage.java
Normal file
89
src/main/java/im/rosetta/network/packet/PacketMessage.java
Normal file
@@ -0,0 +1,89 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
import im.rosetta.network.types.Attachment;
|
||||
|
||||
public class PacketMessage extends Packet {
|
||||
public String fromPublicKey;
|
||||
public String toPublicKey;
|
||||
public String privateKey;
|
||||
public String content;
|
||||
public String chachaKey;
|
||||
public Long timestamp;
|
||||
public String messageId;
|
||||
public java.util.List<Attachment> attachments;
|
||||
public String aesChachaKey;
|
||||
|
||||
public String getFromPublicKey() {
|
||||
return fromPublicKey;
|
||||
}
|
||||
|
||||
public void setFromPublicKey(String fromPublicKey) {
|
||||
this.fromPublicKey = fromPublicKey;
|
||||
}
|
||||
|
||||
public String getToPublicKey() {
|
||||
return toPublicKey;
|
||||
}
|
||||
|
||||
public void setToPublicKey(String toPublicKey) {
|
||||
this.toPublicKey = toPublicKey;
|
||||
}
|
||||
|
||||
public String getPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
public void setPrivateKey(String privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
public String getContent() {
|
||||
return content;
|
||||
}
|
||||
|
||||
public void setContent(String content) {
|
||||
this.content = content;
|
||||
}
|
||||
|
||||
public String getChachaKey() {
|
||||
return chachaKey;
|
||||
}
|
||||
|
||||
public void setChachaKey(String chachaKey) {
|
||||
this.chachaKey = chachaKey;
|
||||
}
|
||||
|
||||
public Long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(Long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
public String getMessageId() {
|
||||
return messageId;
|
||||
}
|
||||
|
||||
public void setMessageId(String messageId) {
|
||||
this.messageId = messageId;
|
||||
}
|
||||
|
||||
public java.util.List<Attachment> getAttachments() {
|
||||
return attachments;
|
||||
}
|
||||
|
||||
public void setAttachments(java.util.List<Attachment> attachments) {
|
||||
this.attachments = attachments;
|
||||
}
|
||||
|
||||
public String getAesChachaKey() {
|
||||
return aesChachaKey;
|
||||
}
|
||||
|
||||
public void setAesChachaKey(String aesChachaKey) {
|
||||
this.aesChachaKey = aesChachaKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,17 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
import im.rosetta.network.types.PKNetworkStatus;
|
||||
|
||||
public class PacketOnlineState extends Packet {
|
||||
public java.util.List<PKNetworkStatus> pkNetworkStatuses;
|
||||
|
||||
public java.util.List<PKNetworkStatus> getPkNetworkStatuses() {
|
||||
return pkNetworkStatuses;
|
||||
}
|
||||
|
||||
public void setPkNetworkStatuses(java.util.List<PKNetworkStatus> pkNetworkStatuses) {
|
||||
this.pkNetworkStatuses = pkNetworkStatuses;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,24 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
public class PacketOnlineSubscribe extends Packet {
|
||||
public String privateKey;
|
||||
public java.util.List<String> publicKeys;
|
||||
|
||||
public String getPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
public void setPrivateKey(String privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
public java.util.List<String> getPublicKeys() {
|
||||
return publicKeys;
|
||||
}
|
||||
|
||||
public void setPublicKeys(java.util.List<String> publicKeys) {
|
||||
this.publicKeys = publicKeys;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,45 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
import im.rosetta.network.enums.NotificationAction;
|
||||
import im.rosetta.network.enums.TokenType;
|
||||
|
||||
public class PacketPushNotification extends Packet {
|
||||
public String notificationToken;
|
||||
public NotificationAction action;
|
||||
public TokenType tokenType;
|
||||
public String deviceId;
|
||||
|
||||
public String getNotificationToken() {
|
||||
return notificationToken;
|
||||
}
|
||||
|
||||
public void setNotificationToken(String notificationToken) {
|
||||
this.notificationToken = notificationToken;
|
||||
}
|
||||
|
||||
public NotificationAction getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
public void setAction(NotificationAction action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
public TokenType getTokenType() {
|
||||
return tokenType;
|
||||
}
|
||||
|
||||
public void setTokenType(TokenType tokenType) {
|
||||
this.tokenType = tokenType;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
}
|
||||
33
src/main/java/im/rosetta/network/packet/PacketRead.java
Normal file
33
src/main/java/im/rosetta/network/packet/PacketRead.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
public class PacketRead extends Packet {
|
||||
public String fromPublicKey;
|
||||
public String toPublicKey;
|
||||
public String privateKey;
|
||||
|
||||
public String getFromPublicKey() {
|
||||
return fromPublicKey;
|
||||
}
|
||||
|
||||
public void setFromPublicKey(String fromPublicKey) {
|
||||
this.fromPublicKey = fromPublicKey;
|
||||
}
|
||||
|
||||
public String getToPublicKey() {
|
||||
return toPublicKey;
|
||||
}
|
||||
|
||||
public void setToPublicKey(String toPublicKey) {
|
||||
this.toPublicKey = toPublicKey;
|
||||
}
|
||||
|
||||
public String getPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
public void setPrivateKey(String privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
public class PacketRequestTransport extends Packet {
|
||||
public String server;
|
||||
|
||||
public String getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public void setServer(String server) {
|
||||
this.server = server;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
public class PacketRequestUpdate extends Packet {
|
||||
public String server;
|
||||
|
||||
public String getServer() {
|
||||
return server;
|
||||
}
|
||||
|
||||
public void setServer(String server) {
|
||||
this.server = server;
|
||||
}
|
||||
}
|
||||
17
src/main/java/im/rosetta/network/packet/PacketResult.java
Normal file
17
src/main/java/im/rosetta/network/packet/PacketResult.java
Normal file
@@ -0,0 +1,17 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
import im.rosetta.network.enums.ResultCode;
|
||||
|
||||
public class PacketResult extends Packet {
|
||||
public ResultCode resultCode;
|
||||
|
||||
public ResultCode getResultCode() {
|
||||
return resultCode;
|
||||
}
|
||||
|
||||
public void setResultCode(ResultCode resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
}
|
||||
35
src/main/java/im/rosetta/network/packet/PacketSearch.java
Normal file
35
src/main/java/im/rosetta/network/packet/PacketSearch.java
Normal file
@@ -0,0 +1,35 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
import im.rosetta.network.types.SearchInfo;
|
||||
|
||||
public class PacketSearch extends Packet {
|
||||
public String privateKey;
|
||||
public String search;
|
||||
public java.util.List<SearchInfo> searchInfo;
|
||||
|
||||
public String getPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
public void setPrivateKey(String privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
public String getSearch() {
|
||||
return search;
|
||||
}
|
||||
|
||||
public void setSearch(String search) {
|
||||
this.search = search;
|
||||
}
|
||||
|
||||
public java.util.List<SearchInfo> getSearchInfo() {
|
||||
return searchInfo;
|
||||
}
|
||||
|
||||
public void setSearchInfo(java.util.List<SearchInfo> searchInfo) {
|
||||
this.searchInfo = searchInfo;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,62 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
import im.rosetta.network.enums.SignalType;
|
||||
|
||||
public class PacketSignalPeer extends Packet {
|
||||
public String src;
|
||||
public String dst;
|
||||
public String sharedPublic;
|
||||
public SignalType signalType;
|
||||
public String callId;
|
||||
public String joinToken;
|
||||
|
||||
public String getSrc() {
|
||||
return src;
|
||||
}
|
||||
|
||||
public void setSrc(String src) {
|
||||
this.src = src;
|
||||
}
|
||||
|
||||
public String getDst() {
|
||||
return dst;
|
||||
}
|
||||
|
||||
public void setDst(String dst) {
|
||||
this.dst = dst;
|
||||
}
|
||||
|
||||
public String getSharedPublic() {
|
||||
return sharedPublic;
|
||||
}
|
||||
|
||||
public void setSharedPublic(String sharedPublic) {
|
||||
this.sharedPublic = sharedPublic;
|
||||
}
|
||||
|
||||
public SignalType getSignalType() {
|
||||
return signalType;
|
||||
}
|
||||
|
||||
public void setSignalType(SignalType signalType) {
|
||||
this.signalType = signalType;
|
||||
}
|
||||
|
||||
public String getCallId() {
|
||||
return callId;
|
||||
}
|
||||
|
||||
public void setCallId(String callId) {
|
||||
this.callId = callId;
|
||||
}
|
||||
|
||||
public String getJoinToken() {
|
||||
return joinToken;
|
||||
}
|
||||
|
||||
public void setJoinToken(String joinToken) {
|
||||
this.joinToken = joinToken;
|
||||
}
|
||||
}
|
||||
26
src/main/java/im/rosetta/network/packet/PacketSync.java
Normal file
26
src/main/java/im/rosetta/network/packet/PacketSync.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
import im.rosetta.network.enums.SyncStatus;
|
||||
|
||||
public class PacketSync extends Packet {
|
||||
public SyncStatus syncStatus;
|
||||
public Long timestamp;
|
||||
|
||||
public SyncStatus getSyncStatus() {
|
||||
return syncStatus;
|
||||
}
|
||||
|
||||
public void setSyncStatus(SyncStatus syncStatus) {
|
||||
this.syncStatus = syncStatus;
|
||||
}
|
||||
|
||||
public Long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
public void setTimestamp(Long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
}
|
||||
33
src/main/java/im/rosetta/network/packet/PacketTypeing.java
Normal file
33
src/main/java/im/rosetta/network/packet/PacketTypeing.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
public class PacketTypeing extends Packet {
|
||||
public String fromPublicKey;
|
||||
public String toPublicKey;
|
||||
public String privateKey;
|
||||
|
||||
public String getFromPublicKey() {
|
||||
return fromPublicKey;
|
||||
}
|
||||
|
||||
public void setFromPublicKey(String fromPublicKey) {
|
||||
this.fromPublicKey = fromPublicKey;
|
||||
}
|
||||
|
||||
public String getToPublicKey() {
|
||||
return toPublicKey;
|
||||
}
|
||||
|
||||
public void setToPublicKey(String toPublicKey) {
|
||||
this.toPublicKey = toPublicKey;
|
||||
}
|
||||
|
||||
public String getPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
public void setPrivateKey(String privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
}
|
||||
33
src/main/java/im/rosetta/network/packet/PacketUserInfo.java
Normal file
33
src/main/java/im/rosetta/network/packet/PacketUserInfo.java
Normal file
@@ -0,0 +1,33 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
public class PacketUserInfo extends Packet {
|
||||
public String privateKey;
|
||||
public String username;
|
||||
public String title;
|
||||
|
||||
public String getPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
public void setPrivateKey(String privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
}
|
||||
26
src/main/java/im/rosetta/network/packet/PacketWebRTC.java
Normal file
26
src/main/java/im/rosetta/network/packet/PacketWebRTC.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package im.rosetta.network.packet;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import io.orprotocol.packet.Packet;
|
||||
import im.rosetta.network.enums.WebRTCType;
|
||||
|
||||
public class PacketWebRTC extends Packet {
|
||||
public String sdpOrCandidate;
|
||||
public WebRTCType type;
|
||||
|
||||
public String getSdpOrCandidate() {
|
||||
return sdpOrCandidate;
|
||||
}
|
||||
|
||||
public void setSdpOrCandidate(String sdpOrCandidate) {
|
||||
this.sdpOrCandidate = sdpOrCandidate;
|
||||
}
|
||||
|
||||
public WebRTCType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(WebRTCType type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
52
src/main/java/im/rosetta/network/types/Attachment.java
Normal file
52
src/main/java/im/rosetta/network/types/Attachment.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package im.rosetta.network.types;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import im.rosetta.network.enums.AttachmentType;
|
||||
|
||||
public class Attachment {
|
||||
public String id;
|
||||
public String blob;
|
||||
public AttachmentType type;
|
||||
public String preview;
|
||||
public AttachmentTransport transport;
|
||||
|
||||
public String getId() {
|
||||
return id;
|
||||
}
|
||||
|
||||
public void setId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String getBlob() {
|
||||
return blob;
|
||||
}
|
||||
|
||||
public void setBlob(String blob) {
|
||||
this.blob = blob;
|
||||
}
|
||||
|
||||
public AttachmentType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
public void setType(AttachmentType type) {
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public String getPreview() {
|
||||
return preview;
|
||||
}
|
||||
|
||||
public void setPreview(String preview) {
|
||||
this.preview = preview;
|
||||
}
|
||||
|
||||
public AttachmentTransport getTransport() {
|
||||
return transport;
|
||||
}
|
||||
|
||||
public void setTransport(AttachmentTransport transport) {
|
||||
this.transport = transport;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,23 @@
|
||||
package im.rosetta.network.types;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class AttachmentTransport {
|
||||
public String transportTag;
|
||||
public String transportServer;
|
||||
|
||||
public String getTransportTag() {
|
||||
return transportTag;
|
||||
}
|
||||
|
||||
public void setTransportTag(String transportTag) {
|
||||
this.transportTag = transportTag;
|
||||
}
|
||||
|
||||
public String getTransportServer() {
|
||||
return transportServer;
|
||||
}
|
||||
|
||||
public void setTransportServer(String transportServer) {
|
||||
this.transportServer = transportServer;
|
||||
}
|
||||
}
|
||||
@@ -1,29 +1,15 @@
|
||||
package im.rosetta.packet.runtime;
|
||||
package im.rosetta.network.types;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import im.rosetta.network.enums.DeviceSolution;
|
||||
import im.rosetta.network.enums.NetworkStatus;
|
||||
|
||||
/**
|
||||
* Обозначает подключенное к аккаунту устройство, с которого
|
||||
* был произведен вход в систему.
|
||||
*/
|
||||
public class NetworkDevice {
|
||||
|
||||
private NetworkStatus networkStatus;
|
||||
private String deviceName;
|
||||
private String deviceOs;
|
||||
private String deviceId;
|
||||
private DeviceSolution deviceSolution;
|
||||
|
||||
public NetworkDevice() {
|
||||
}
|
||||
|
||||
public NetworkDevice(NetworkStatus networkStatus, String deviceName, String deviceOs, String deviceId,
|
||||
DeviceSolution deviceSolution) {
|
||||
this.networkStatus = networkStatus;
|
||||
this.deviceName = deviceName;
|
||||
this.deviceOs = deviceOs;
|
||||
this.deviceId = deviceId;
|
||||
this.deviceSolution = deviceSolution;
|
||||
}
|
||||
|
||||
public NetworkStatus networkStatus;
|
||||
public String deviceName;
|
||||
public String deviceOs;
|
||||
public String deviceId;
|
||||
public DeviceSolution deviceSolution;
|
||||
|
||||
public NetworkStatus getNetworkStatus() {
|
||||
return networkStatus;
|
||||
@@ -64,5 +50,4 @@ public class NetworkDevice {
|
||||
public void setDeviceSolution(DeviceSolution deviceSolution) {
|
||||
this.deviceSolution = deviceSolution;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,21 +1,12 @@
|
||||
package im.rosetta.packet.runtime;
|
||||
package im.rosetta.network.types;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import im.rosetta.network.enums.NetworkStatus;
|
||||
|
||||
/**
|
||||
* Сущность для обозначения статуса сети
|
||||
* пользователя по публичному ключу
|
||||
*/
|
||||
public class PKNetworkStatus {
|
||||
|
||||
public String publicKey;
|
||||
public NetworkStatus networkStatus;
|
||||
|
||||
public PKNetworkStatus() {}
|
||||
|
||||
public PKNetworkStatus(String publicKey, NetworkStatus networkStatus) {
|
||||
this.publicKey = publicKey;
|
||||
this.networkStatus = networkStatus;
|
||||
}
|
||||
|
||||
public String getPublicKey() {
|
||||
return publicKey;
|
||||
}
|
||||
@@ -31,5 +22,4 @@ public class PKNetworkStatus {
|
||||
public void setNetworkStatus(NetworkStatus networkStatus) {
|
||||
this.networkStatus = networkStatus;
|
||||
}
|
||||
|
||||
}
|
||||
41
src/main/java/im/rosetta/network/types/RTCIceServer.java
Normal file
41
src/main/java/im/rosetta/network/types/RTCIceServer.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package im.rosetta.network.types;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
public class RTCIceServer {
|
||||
public String url;
|
||||
public String username;
|
||||
public String credential;
|
||||
public String transport;
|
||||
|
||||
public String getUrl() {
|
||||
return url;
|
||||
}
|
||||
|
||||
public void setUrl(String url) {
|
||||
this.url = url;
|
||||
}
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getCredential() {
|
||||
return credential;
|
||||
}
|
||||
|
||||
public void setCredential(String credential) {
|
||||
this.credential = credential;
|
||||
}
|
||||
|
||||
public String getTransport() {
|
||||
return transport;
|
||||
}
|
||||
|
||||
public void setTransport(String transport) {
|
||||
this.transport = transport;
|
||||
}
|
||||
}
|
||||
52
src/main/java/im/rosetta/network/types/SearchInfo.java
Normal file
52
src/main/java/im/rosetta/network/types/SearchInfo.java
Normal file
@@ -0,0 +1,52 @@
|
||||
package im.rosetta.network.types;
|
||||
|
||||
// Auto-generated by RCC (Rosetta Code Compiler). Do not edit manually.
|
||||
import im.rosetta.network.enums.NetworkStatus;
|
||||
|
||||
public class SearchInfo {
|
||||
public String username;
|
||||
public String title;
|
||||
public String publicKey;
|
||||
public Integer verified;
|
||||
public NetworkStatus networkStatus;
|
||||
|
||||
public String getUsername() {
|
||||
return username;
|
||||
}
|
||||
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
public String getTitle() {
|
||||
return title;
|
||||
}
|
||||
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
|
||||
public String getPublicKey() {
|
||||
return publicKey;
|
||||
}
|
||||
|
||||
public void setPublicKey(String publicKey) {
|
||||
this.publicKey = publicKey;
|
||||
}
|
||||
|
||||
public Integer getVerified() {
|
||||
return verified;
|
||||
}
|
||||
|
||||
public void setVerified(Integer verified) {
|
||||
this.verified = verified;
|
||||
}
|
||||
|
||||
public NetworkStatus getNetworkStatus() {
|
||||
return networkStatus;
|
||||
}
|
||||
|
||||
public void setNetworkStatus(NetworkStatus networkStatus) {
|
||||
this.networkStatus = networkStatus;
|
||||
}
|
||||
}
|
||||
@@ -1,156 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import im.rosetta.packet.runtime.HandshakeStage;
|
||||
|
||||
import io.orprotocol.Stream;
|
||||
import io.orprotocol.packet.Packet;
|
||||
|
||||
/**
|
||||
* Пакет хэндшейка между клиентом и сервером.
|
||||
* Используется для установления соединения и подтверждения от сервера что клиент
|
||||
* тот за кого себя выдает.
|
||||
*
|
||||
* Протокол таблица:
|
||||
* 0 - packetId (int16)
|
||||
* 1 - privateKey (string)
|
||||
* 2 - publicKey (string)
|
||||
* 3 - protocolVersion (int8)
|
||||
* 4 - heartbeatInterval (int8)
|
||||
* 5 - deviceId (string)
|
||||
* 6 - deviceName (string)
|
||||
* 7 - deviceOs (string)
|
||||
* 8 - handshakeStage (int8)
|
||||
*/
|
||||
public class Packet0Handshake extends Packet {
|
||||
/**
|
||||
* Публичный и приватный ключи клиента
|
||||
*/
|
||||
private String publicKey;
|
||||
/**
|
||||
* Приватный ключ клиента
|
||||
* Это не совсем приватный ключ, а лишь необратимо зашифрованная его версия
|
||||
* для идентификации клиента на сервере.
|
||||
*/
|
||||
private String privateKey;
|
||||
/**
|
||||
* Версия протокола клиента
|
||||
*/
|
||||
private int protocolVersion = 1;
|
||||
|
||||
/**
|
||||
* Интервал отправки heartbeat пакетов в секундах
|
||||
*/
|
||||
private int heartbeatInterval = 15;
|
||||
|
||||
/**
|
||||
* Минимальная информация об устройстве клиента
|
||||
*/
|
||||
private String deviceId;
|
||||
private String deviceName;
|
||||
private String deviceOs;
|
||||
|
||||
/**
|
||||
* Стадия рукопожатия
|
||||
* 0 - COMPLETED
|
||||
* 1 - NEED_DEVICE_VERIFICATION
|
||||
*/
|
||||
private HandshakeStage handshakeStage = HandshakeStage.COMPLETED;
|
||||
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream stream = new Stream();
|
||||
stream.writeInt16(this.packetId);
|
||||
stream.writeString(this.privateKey);
|
||||
stream.writeString(this.publicKey);
|
||||
stream.writeInt8(this.protocolVersion);
|
||||
stream.writeInt8(this.heartbeatInterval);
|
||||
stream.writeString(this.deviceId);
|
||||
stream.writeString(this.deviceName);
|
||||
stream.writeString(this.deviceOs);
|
||||
stream.writeInt8(this.handshakeStage.getCode());
|
||||
return stream;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
this.privateKey = stream.readString();
|
||||
this.publicKey = stream.readString();
|
||||
this.protocolVersion = stream.readInt8();
|
||||
this.heartbeatInterval = stream.readInt8();
|
||||
String deviceId = stream.readString();
|
||||
String deviceName = stream.readString();
|
||||
String deviceOs = stream.readString();
|
||||
this.deviceId = deviceId;
|
||||
this.deviceName = deviceName;
|
||||
this.deviceOs = deviceOs;
|
||||
this.handshakeStage = HandshakeStage.fromCode(
|
||||
stream.readInt8()
|
||||
);
|
||||
}
|
||||
|
||||
public String getPublicKey() {
|
||||
return publicKey;
|
||||
}
|
||||
|
||||
public String getPrivateKey() {
|
||||
return privateKey;
|
||||
}
|
||||
|
||||
public int getProtocolVersion() {
|
||||
return protocolVersion;
|
||||
}
|
||||
|
||||
public int getHeartbeatInterval() {
|
||||
return heartbeatInterval;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public String getDeviceName() {
|
||||
return deviceName;
|
||||
}
|
||||
|
||||
public String getDeviceOs() {
|
||||
return deviceOs;
|
||||
}
|
||||
|
||||
public HandshakeStage getHandshakeStage() {
|
||||
return handshakeStage;
|
||||
}
|
||||
|
||||
public void setHandshakeStage(HandshakeStage handshakeStage) {
|
||||
this.handshakeStage = handshakeStage;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceName(String deviceName) {
|
||||
this.deviceName = deviceName;
|
||||
}
|
||||
|
||||
public void setDeviceOs(String deviceOs) {
|
||||
this.deviceOs = deviceOs;
|
||||
}
|
||||
|
||||
public void setHeartbeatInterval(int heartbeatInterval) {
|
||||
this.heartbeatInterval = heartbeatInterval;
|
||||
}
|
||||
|
||||
public void setProtocolVersion(int protocolVersion) {
|
||||
this.protocolVersion = protocolVersion;
|
||||
}
|
||||
|
||||
public void setPrivateKey(String privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
public void setPublicKey(String publicKey) {
|
||||
this.publicKey = publicKey;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,14 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import im.rosetta.packet.base.PacketBaseServer;
|
||||
|
||||
/**
|
||||
* Получает сервер обновления
|
||||
*/
|
||||
public class Packet10RequestUpdate extends PacketBaseServer {
|
||||
/**
|
||||
* Пустой пакет, так как он наследник PacketBaseServer
|
||||
* который всегда имеет одну структуру.
|
||||
* Смотреть PacketBaseServer для реализации
|
||||
*/
|
||||
}
|
||||
@@ -1,29 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import im.rosetta.packet.base.PacketBaseDialog;
|
||||
|
||||
import io.orprotocol.Stream;
|
||||
|
||||
/**
|
||||
* Пакет отвечающий за индикацию печати в диалогах
|
||||
*/
|
||||
public class Packet11Typeing extends PacketBaseDialog {
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
this.privateKey = stream.readString();
|
||||
this.fromPublicKey = stream.readString();
|
||||
this.toPublicKey = stream.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream stream = new Stream();
|
||||
stream.writeInt16(this.packetId);
|
||||
stream.writeString(this.privateKey);
|
||||
stream.writeString(this.fromPublicKey);
|
||||
stream.writeString(this.toPublicKey);
|
||||
return stream;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,16 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import im.rosetta.packet.base.PacketBaseServer;
|
||||
|
||||
/**
|
||||
* Пакет отправляется клиентом для запроса транспортного сервера, строка в этот момент клиентом
|
||||
* не заполняется, а уже обратно сервер заполняет строку и записывает туда транспортный сервер
|
||||
* чтобы клиент мог отправлять вложения на него
|
||||
*/
|
||||
public class Packet15RequestTransport extends PacketBaseServer {
|
||||
/**
|
||||
* Пустой пакет, так как он наследник PacketBaseServer
|
||||
* который всегда имеет одну структуру.
|
||||
* Смотреть PacketBaseServer для реализации
|
||||
*/
|
||||
}
|
||||
@@ -1,101 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import im.rosetta.packet.runtime.NetworkNotificationAction;
|
||||
import im.rosetta.packet.runtime.TokenType;
|
||||
import io.orprotocol.Stream;
|
||||
import io.orprotocol.packet.Packet;
|
||||
|
||||
/**
|
||||
* Packet16PushNotification бросается клиентом для подписки на пуш уведомления
|
||||
*/
|
||||
public class Packet16PushNotification extends Packet {
|
||||
|
||||
private String notificationToken;
|
||||
private NetworkNotificationAction action;
|
||||
private TokenType tokenType;
|
||||
private String deviceId;
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
this.notificationToken = stream.readString();
|
||||
this.action = NetworkNotificationAction.fromCode(stream.readInt8());
|
||||
this.tokenType = TokenType.fromCode(stream.readInt8());
|
||||
this.deviceId = stream.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream stream = new Stream();
|
||||
stream.writeInt16(this.packetId);
|
||||
stream.writeString(notificationToken);
|
||||
stream.writeInt8(action.getCode());
|
||||
stream.writeInt8(tokenType.getCode());
|
||||
stream.writeString(deviceId);
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить токен пуш уведомлений, который нужно подписать или отписать в зависимости от action
|
||||
* @return токен пуш уведомлений
|
||||
*/
|
||||
public String getNotificationToken() {
|
||||
return notificationToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить действие, которое нужно выполнить с токеном пуш уведомлений. SUBSCRIBE - подписать этот токен на пуш уведомления, UNSUBSCRIBE - отписать этот токен от пуш уведомлений
|
||||
* @return действие, которое нужно выполнить с токеном пуш уведомлений
|
||||
*/
|
||||
public NetworkNotificationAction getAction() {
|
||||
return action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает токен пуш уведомлений, который нужно подписать или отписать в зависимости от action
|
||||
* @param notificationToken токен пуш уведомлений
|
||||
*/
|
||||
public void setNotificationToken(String notificationToken) {
|
||||
this.notificationToken = notificationToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает действие, которое нужно выполнить с токеном пуш уведомлений. SUBSCRIBE - подписать этот токен на пуш уведомления, UNSUBSCRIBE - отписать этот токен от пуш уведомлений
|
||||
* @param action действие, которое нужно выполнить с токеном пуш уведомлений
|
||||
*/
|
||||
public void setAction(NetworkNotificationAction action) {
|
||||
this.action = action;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает тип токена пуш уведомлений.
|
||||
* @param tokenType тип токена пуш уведомлений
|
||||
*/
|
||||
public void setTokenType(TokenType tokenType) {
|
||||
this.tokenType = tokenType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить тип токена пуш уведомлений, который нужно подписать или отписать в зависимости от action
|
||||
* @return тип токена пуш уведомлений
|
||||
*/
|
||||
public TokenType getTokenType() {
|
||||
return tokenType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Девайс которому принадлежит токен пуш уведомлений, который нужно подписать или отписать в зависимости от action
|
||||
* @return
|
||||
*/
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает девайс которому принадлежит токен пуш уведомлений, который нужно подписать или отписать в зависимости от action
|
||||
* @param deviceId девайс которому принадлежит токен пуш уведомлений
|
||||
*/
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,39 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import io.orprotocol.Stream;
|
||||
import io.orprotocol.packet.Packet;
|
||||
|
||||
public class Packet17GroupCreate extends Packet {
|
||||
|
||||
private String groupId;
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
this.groupId = stream.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream stream = new Stream();
|
||||
stream.writeInt16(this.packetId);
|
||||
stream.writeString(this.groupId);
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить id группы, которую нужно создать
|
||||
* @return id группы, которую нужно создать
|
||||
*/
|
||||
public String getGroupId() {
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить id группы, которую нужно создать
|
||||
* @param groupId id группы, которую нужно создать
|
||||
*/
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,67 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import io.orprotocol.Stream;
|
||||
import io.orprotocol.packet.Packet;
|
||||
|
||||
public class Packet18GroupInfo extends Packet {
|
||||
|
||||
private String groupId;
|
||||
private List<String> membersPKs;
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
this.groupId = stream.readString();
|
||||
int membersCount = stream.readInt16();
|
||||
this.membersPKs = new java.util.ArrayList<>();
|
||||
for(int i = 0; i < membersCount; i++) {
|
||||
this.membersPKs.add(stream.readString());
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream stream = new Stream();
|
||||
stream.writeInt16(this.packetId);
|
||||
stream.writeString(this.groupId);
|
||||
stream.writeInt16(this.membersPKs.size());
|
||||
for(String memberPK : this.membersPKs) {
|
||||
stream.writeString(memberPK);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить id группы
|
||||
* @return id группы
|
||||
*/
|
||||
public String getGroupId() {
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить id группы
|
||||
* @param groupId id группы
|
||||
*/
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить публичные ключи участников группы
|
||||
* @return список публичных ключей участников группы
|
||||
*/
|
||||
public List<String> getMembersPKs() {
|
||||
return this.membersPKs;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить публичные ключи участников группы
|
||||
* @param membersPKs список публичных ключей участников группы
|
||||
*/
|
||||
public void setMembersPKs(List<String> membersPKs) {
|
||||
this.membersPKs = membersPKs;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,82 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import im.rosetta.packet.runtime.NetworkGroupStatus;
|
||||
|
||||
import io.orprotocol.Stream;
|
||||
import io.orprotocol.packet.Packet;
|
||||
|
||||
/**
|
||||
* Пакет который бросается клиентом для определения статуса приглашения в группу
|
||||
*/
|
||||
public class Packet19GroupInviteInfo extends Packet {
|
||||
|
||||
private String groupId;
|
||||
private int membersCount;
|
||||
private NetworkGroupStatus status;
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
this.groupId = stream.readString();
|
||||
this.membersCount = stream.readInt16();
|
||||
this.status = NetworkGroupStatus.fromCode(stream.readInt8());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream stream = new Stream();
|
||||
stream.writeInt16(this.packetId);
|
||||
stream.writeString(this.groupId);
|
||||
stream.writeInt16(this.membersCount);
|
||||
stream.writeInt8(this.status.getCode());
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить id группы
|
||||
* @return id группы
|
||||
*/
|
||||
public String getGroupId() {
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить id группы
|
||||
* @param groupId id группы
|
||||
*/
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить количество участников в группе
|
||||
* @return количество участников в группе
|
||||
*/
|
||||
public int getMembersCount() {
|
||||
return this.membersCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить количество участников в группе
|
||||
* @param membersCount количество участников в группе
|
||||
*/
|
||||
public void setMembersCount(int membersCount) {
|
||||
this.membersCount = membersCount;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить статус приглашения в группу
|
||||
* @return статус приглашения в группу
|
||||
*/
|
||||
public NetworkGroupStatus getStatus() {
|
||||
return this.status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить статус приглашения в группу
|
||||
* @param status статус приглашения в группу
|
||||
*/
|
||||
public void setStatus(NetworkGroupStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,84 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import io.orprotocol.Stream;
|
||||
import io.orprotocol.packet.Packet;
|
||||
|
||||
public class Packet1UserInfo extends Packet {
|
||||
|
||||
@Deprecated(since = "1.1", forRemoval = true)
|
||||
private String privateKey;
|
||||
|
||||
private String username;
|
||||
private String title;
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
this.username = stream.readString();
|
||||
this.title = stream.readString();
|
||||
this.privateKey = stream.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream steram = new Stream();
|
||||
steram.writeInt16(this.packetId);
|
||||
steram.writeString(this.username);
|
||||
steram.writeString(this.title);
|
||||
steram.writeString(this.privateKey);
|
||||
return steram;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Получает приватный ключ пользователя
|
||||
* @return приватный ключ
|
||||
* @deprecated с версии сервера 1.1 использование приватных ключей
|
||||
* в протоколе устарело, так как теперь сервер использует Handshake для аутентификации пользователей.
|
||||
*/
|
||||
@Deprecated(since = "1.1", forRemoval = true)
|
||||
public String getPrivateKey() {
|
||||
return this.privateKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает приватный ключ пользователя
|
||||
* @param privateKey приватный ключ
|
||||
* @deprecated с версии сервера 1.1 использование приватных ключей
|
||||
* в протоколе устарело, так как теперь сервер использует Handshake для аутентификации пользователей.
|
||||
*/
|
||||
public void setPrivateKey(String privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает имя пользователя
|
||||
* @return имя пользователя
|
||||
*/
|
||||
public String getUsername() {
|
||||
return this.username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Возвращает заголовок (титул) пользователя
|
||||
* @return заголовок пользователя
|
||||
*/
|
||||
public String getTitle() {
|
||||
return this.title;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает имя пользователя
|
||||
* @param username имя пользователя
|
||||
*/
|
||||
public void setUsername(String username) {
|
||||
this.username = username;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает заголовок (титул) пользователя
|
||||
* @param title заголовок пользователя
|
||||
*/
|
||||
public void setTitle(String title) {
|
||||
this.title = title;
|
||||
}
|
||||
}
|
||||
@@ -1,91 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import im.rosetta.packet.runtime.NetworkGroupStatus;
|
||||
|
||||
import io.orprotocol.Stream;
|
||||
import io.orprotocol.packet.Packet;
|
||||
|
||||
/**
|
||||
* Вызывается клиентом для вступления в группу.
|
||||
* Сервер модифицирует этот пакет, устанавливая статус группы, и отправляет его обратно
|
||||
* клиенту
|
||||
*/
|
||||
public class Packet20GroupJoin extends Packet {
|
||||
|
||||
private String groupId;
|
||||
private NetworkGroupStatus status;
|
||||
/**
|
||||
* Строка группы, которая содержит информацию о группе, такую как ее название, описание и ключ
|
||||
* Строка зашифрована обратимым шифрованием, где ключом выступает - реальный приватный ключ
|
||||
* входящего в группу клиента. Нужно это для будущей синхронзации, так как клиенту на его другом
|
||||
* устройстве нужно получить ключ группы и ее информацию. Сервер расшифровать эту строку не может. Эту
|
||||
* строку может расшифровать только клиент, так как она зашифрована его приватным ключом
|
||||
*/
|
||||
private String groupString;
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
this.groupId = stream.readString();
|
||||
this.status = NetworkGroupStatus.fromCode(stream.readInt8());
|
||||
this.groupString = stream.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream stream = new Stream();
|
||||
stream.writeInt16(this.packetId);
|
||||
stream.writeString(this.groupId);
|
||||
stream.writeInt8(this.status.getCode());
|
||||
stream.writeString(this.groupString);
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить id группы
|
||||
* @return id группы
|
||||
*/
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить id группы
|
||||
* @param groupId id группы
|
||||
*/
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить статус группы
|
||||
* @return статус группы
|
||||
*/
|
||||
public NetworkGroupStatus getStatus() {
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить статус группы
|
||||
* @param status статус группы
|
||||
*/
|
||||
public void setStatus(NetworkGroupStatus status) {
|
||||
this.status = status;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить строку группы, которая содержит информацию о группе, такую как ее название, описание и ключ
|
||||
* @return строка группы
|
||||
*/
|
||||
public String getGroupString() {
|
||||
return groupString;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить строку группы, которая содержит информацию о группе, такую как ее название, описание и ключ
|
||||
* @param groupString строка группы
|
||||
*/
|
||||
public void setGroupString(String groupString) {
|
||||
this.groupString = groupString;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import io.orprotocol.Stream;
|
||||
import io.orprotocol.packet.Packet;
|
||||
|
||||
/**
|
||||
* Вызывается клиентом для выхода из группы. Содержит id группы, которую нужно покинуть
|
||||
*/
|
||||
public class Packet21GroupLeave extends Packet {
|
||||
|
||||
private String groupId;
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
this.groupId = stream.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream stream = new Stream();
|
||||
stream.writeInt16(this.packetId);
|
||||
stream.writeString(this.groupId);
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить id группы, которую нужно покинуть
|
||||
* @return id группы, которую нужно покинуть
|
||||
*/
|
||||
public String getGroupId() {
|
||||
return this.groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить id группы, которую нужно покинуть
|
||||
* @param groupId id группы, которую нужно покинуть
|
||||
*/
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import io.orprotocol.Stream;
|
||||
import io.orprotocol.packet.Packet;
|
||||
|
||||
public class Packet22GroupBan extends Packet {
|
||||
|
||||
private String groupId;
|
||||
private String publicKey;
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
this.groupId = stream.readString();
|
||||
this.publicKey = stream.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream stream = new Stream();
|
||||
stream.writeInt16(this.packetId);
|
||||
stream.writeString(this.groupId);
|
||||
stream.writeString(this.publicKey);
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить id группы, в которой нужно забанить пользователя
|
||||
* @return id группы
|
||||
*/
|
||||
public String getGroupId() {
|
||||
return groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить id группы, в которой нужно забанить пользователя
|
||||
* @param groupId id группы
|
||||
*/
|
||||
public void setGroupId(String groupId) {
|
||||
this.groupId = groupId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить публичный ключ пользователя, которого нужно забанить в группе
|
||||
* @return публичный ключ пользователя
|
||||
*/
|
||||
public String getPublicKey() {
|
||||
return publicKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить публичный ключ пользователя, которого нужно забанить в группе
|
||||
* @param publicKey публичный ключ
|
||||
*/
|
||||
public void setPublicKey(String publicKey) {
|
||||
this.publicKey = publicKey;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,62 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import im.rosetta.packet.runtime.DeviceSolution;
|
||||
import im.rosetta.packet.runtime.NetworkDevice;
|
||||
import im.rosetta.packet.runtime.NetworkStatus;
|
||||
|
||||
import io.orprotocol.Stream;
|
||||
import io.orprotocol.packet.Packet;
|
||||
|
||||
/**
|
||||
* Пакет, который содержит список устройств, с которых был произведен вход в систему.
|
||||
* Этот пакет может быть отправлен сервером в ответ на запрос клиента о получении списка устройств,
|
||||
* или может быть отправлен сервером при обнаружении нового входа в систему с нового устройства, чтобы уведомить клиента о новом устройстве.
|
||||
*/
|
||||
public class Packet23DeviceList extends Packet {
|
||||
|
||||
private List<NetworkDevice> devices;
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
int deviceCount = stream.readInt16();
|
||||
this.devices = new java.util.ArrayList<>();
|
||||
for(int i = 0; i < deviceCount; i++) {
|
||||
NetworkDevice netDevice = new NetworkDevice();
|
||||
netDevice.setDeviceId(stream.readString());
|
||||
netDevice.setDeviceName(stream.readString());
|
||||
netDevice.setDeviceOs(stream.readString());
|
||||
/**
|
||||
* TODO: Использовать boolean для обозначения статуса сети, а не int8.
|
||||
*/
|
||||
netDevice.setNetworkStatus(NetworkStatus.fromCode(stream.readInt8()));
|
||||
netDevice.setDeviceSolution(DeviceSolution.fromCode(stream.readInt8()));
|
||||
this.devices.add(netDevice);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream stream = new Stream();
|
||||
stream.writeInt16(this.packetId);
|
||||
stream.writeInt16(this.devices.size());
|
||||
for(NetworkDevice device : this.devices) {
|
||||
stream.writeString(device.getDeviceId());
|
||||
stream.writeString(device.getDeviceName());
|
||||
stream.writeString(device.getDeviceOs());
|
||||
stream.writeInt8(device.getNetworkStatus().getCode());
|
||||
stream.writeInt8(device.getDeviceSolution().getCode());
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
public List<NetworkDevice> getDevices() {
|
||||
return devices;
|
||||
}
|
||||
|
||||
public void setDevices(List<NetworkDevice> devices) {
|
||||
this.devices = devices;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,48 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import im.rosetta.packet.runtime.DeviceSolution;
|
||||
|
||||
import io.orprotocol.Stream;
|
||||
import io.orprotocol.packet.Packet;
|
||||
|
||||
/**
|
||||
* Пакет для решения по запросу на добавление устройства
|
||||
* Принимается от клиента, который получил запрос на добавление устройства, и отправляется серверу для обработки решения
|
||||
*/
|
||||
public class Packet24DeviceResolve extends Packet {
|
||||
|
||||
private String deviceId;
|
||||
private DeviceSolution solution;
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
this.deviceId = stream.readString();
|
||||
this.solution = DeviceSolution.fromCode(stream.readInt8());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream stream = new Stream();
|
||||
stream.writeInt16(this.packetId);
|
||||
stream.writeString(this.deviceId);
|
||||
stream.writeInt8(this.solution.getCode());
|
||||
return stream;
|
||||
}
|
||||
|
||||
public String getDeviceId() {
|
||||
return deviceId;
|
||||
}
|
||||
|
||||
public void setDeviceId(String deviceId) {
|
||||
this.deviceId = deviceId;
|
||||
}
|
||||
|
||||
public DeviceSolution getSolution() {
|
||||
return solution;
|
||||
}
|
||||
|
||||
public void setSolution(DeviceSolution solution) {
|
||||
this.solution = solution;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,66 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import im.rosetta.packet.runtime.NetworkSyncStatus;
|
||||
import io.orprotocol.Stream;
|
||||
import io.orprotocol.packet.Packet;
|
||||
|
||||
/**
|
||||
* Пакет отправляет клиент устанавливая timestamp последнего синхронизированного пакета,
|
||||
* а так же статус синхронизации, который может быть:
|
||||
* NOT_NEEDED - синхронизация не требуется, так как устройство уже синхронизировано или не требует синхронизации
|
||||
* BATCH_START - начало синхронизации, сервер начинает отправлять клиенту пакеты для синхронизации, клиент должен подготовиться к приему пакетов для синхронизации
|
||||
* BATCH_END - конец синхронизации, сервер завершил отправку пакетов для синхронизации, клиент может завершить процесс синхронизации
|
||||
*/
|
||||
public class Packet25Sync extends Packet {
|
||||
|
||||
private NetworkSyncStatus syncStatus;
|
||||
private long timestamp;
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
this.syncStatus = NetworkSyncStatus.fromValue(stream.readInt8());
|
||||
this.timestamp = stream.readInt64();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream stream = new Stream();
|
||||
stream.writeInt16(this.packetId);
|
||||
stream.writeInt8(this.syncStatus.getValue());
|
||||
stream.writeInt64(this.timestamp);
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить статус синхронизации
|
||||
* @return статус синхронизации
|
||||
*/
|
||||
public NetworkSyncStatus getSyncStatus() {
|
||||
return syncStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить статус синхронизации
|
||||
* @param syncStatus статус синхронизации
|
||||
*/
|
||||
public void setSyncStatus(NetworkSyncStatus syncStatus) {
|
||||
this.syncStatus = syncStatus;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить timestamp последнего синхронизированного пакета
|
||||
* @return timestamp последнего синхронизированного пакета
|
||||
*/
|
||||
public long getTimestamp() {
|
||||
return timestamp;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить timestamp последнего синхронизированного пакета
|
||||
* @param timestamp timestamp последнего синхронизированного пакета
|
||||
*/
|
||||
public void setTimestamp(long timestamp) {
|
||||
this.timestamp = timestamp;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,174 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import im.rosetta.packet.runtime.NetworkSignalType;
|
||||
import io.orprotocol.Stream;
|
||||
import io.orprotocol.packet.Packet;
|
||||
|
||||
/**
|
||||
* Пакет cигналинга для совершения звонка. Учавствует в обмене ключами,
|
||||
* иницилизации звонка.
|
||||
*/
|
||||
public class Packet26SignalPeer extends Packet {
|
||||
|
||||
/**
|
||||
* Идентификатор отправителя сигнала, обычно это PK пользователя, который отправляет пакет
|
||||
*/
|
||||
private String src;
|
||||
/**
|
||||
* Идентификатор получателя сигнала, обычно это PK пользователя, который должен принять пакет
|
||||
*/
|
||||
private String dst;
|
||||
|
||||
/**
|
||||
* Если сигнал предназначен для обмена ключами, то в это поле
|
||||
* будет помещаться sharedPublic публичная часть ключа DH алгоритма
|
||||
*/
|
||||
private String sharedPublic;
|
||||
|
||||
/**
|
||||
* Тип сигнала
|
||||
*/
|
||||
private NetworkSignalType signalType;
|
||||
/**
|
||||
* callId и joinToken нужны для того, чтобы идентифицировать сессию звонка. Так как roomId это только ID комнаты на sfu
|
||||
*/
|
||||
private String callId;
|
||||
private String joinToken;
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
this.signalType = NetworkSignalType.fromCode(stream.readInt8());
|
||||
if(this.signalType == NetworkSignalType.END_CALL_BECAUSE_BUSY
|
||||
|| this.signalType == NetworkSignalType.END_CALL_BECAUSE_PEER_DISCONNECTED
|
||||
|| this.signalType == NetworkSignalType.RINGING_TIMEOUT) {
|
||||
return;
|
||||
}
|
||||
this.src = stream.readString();
|
||||
this.dst = stream.readString();
|
||||
if (signalType == NetworkSignalType.KEY_EXCHANGE) {
|
||||
this.sharedPublic = stream.readString();
|
||||
}
|
||||
if(signalType == NetworkSignalType.CALL || signalType == NetworkSignalType.ACCEPT || signalType == NetworkSignalType.END_CALL) {
|
||||
this.callId = stream.readString();
|
||||
this.joinToken = stream.readString();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream stream = new Stream();
|
||||
stream.writeInt16(this.packetId);
|
||||
stream.writeInt8(this.signalType.getCode());
|
||||
if(this.signalType == NetworkSignalType.END_CALL_BECAUSE_BUSY
|
||||
|| this.signalType == NetworkSignalType.END_CALL_BECAUSE_PEER_DISCONNECTED
|
||||
|| this.signalType == NetworkSignalType.RINGING_TIMEOUT) {
|
||||
return stream;
|
||||
}
|
||||
stream.writeString(this.src);
|
||||
stream.writeString(this.dst);
|
||||
if (signalType == NetworkSignalType.KEY_EXCHANGE) {
|
||||
stream.writeString(this.sharedPublic);
|
||||
}
|
||||
if(signalType == NetworkSignalType.CALL || signalType == NetworkSignalType.ACCEPT || signalType == NetworkSignalType.END_CALL) {
|
||||
stream.writeString(this.callId);
|
||||
stream.writeString(this.joinToken);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить идентификатор отправителя сигнала
|
||||
* @return идентификатор отправителя сигнала
|
||||
*/
|
||||
public String getSrc() {
|
||||
return src;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить идентификатор отправителя сигнала
|
||||
* @param src идентификатор отправителя сигнала
|
||||
*/
|
||||
public void setSrc(String src) {
|
||||
this.src = src;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить идентификатор получателя сигнала
|
||||
* @return идентификатор получателя сигнала
|
||||
*/
|
||||
public String getDst() {
|
||||
return dst;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить идентификатор получателя сигнала
|
||||
* @param dst идентификатор получателя сигнала
|
||||
*/
|
||||
public void setDst(String dst) {
|
||||
this.dst = dst;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить публичную часть ключа DH алгоритма, если сигнал предназначен для обмена ключами
|
||||
* @return публичная часть ключа DH алгоритма или null, если сигнал не предназначен для обмена ключами
|
||||
*/
|
||||
public String getSharedPublic() {
|
||||
return sharedPublic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить публичную часть ключа DH алгоритма, если сигнал предназначен для обмена ключами
|
||||
* @param sharedPublic публичная часть ключа DH алгоритма
|
||||
*/
|
||||
public void setSharedPublic(String sharedPublic) {
|
||||
this.sharedPublic = sharedPublic;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить тип сигнала
|
||||
* @return тип сигнала
|
||||
*/
|
||||
|
||||
public NetworkSignalType getSignalType() {
|
||||
return signalType;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить тип сигнала
|
||||
* @param signalType тип сигнала
|
||||
*/
|
||||
public void setSignalType(NetworkSignalType signalType) {
|
||||
this.signalType = signalType;
|
||||
}
|
||||
/**
|
||||
* Получить идентификатор сессии звонка, если тип сигнала CALL или ACCEPT
|
||||
* @return идентификатор сессии звонка, если тип сигнала CALL или ACCEPT, иначе null
|
||||
*/
|
||||
public String getCallId() {
|
||||
return callId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить идентификатор сессии звонка, если тип сигнала CALL или ACCEPT
|
||||
* @param callId идентификатор сессии звонка, если тип сигнала CALL или ACCEPT
|
||||
*/
|
||||
public void setCallId(String callId) {
|
||||
this.callId = callId;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить токен для присоединения к сессии звонка, если тип сигнала CALL или ACCEPT
|
||||
* @return токен для присоединения к сессии звонка, если тип сигнала CALL или ACCEPT, иначе null
|
||||
*/
|
||||
public String getJoinToken() {
|
||||
return joinToken;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить токен для присоединения к сессии звонка, если тип сигнала CALL или ACCEPT
|
||||
* @param joinToken токен для присоединения к сессии звонка, если тип сигнала CALL или ACCEPT
|
||||
*/
|
||||
public void setJoinToken(String joinToken) {
|
||||
this.joinToken = joinToken;
|
||||
}
|
||||
}
|
||||
@@ -1,63 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import im.rosetta.packet.runtime.NetworkWebRTCType;
|
||||
import io.orprotocol.Stream;
|
||||
import io.orprotocol.packet.Packet;
|
||||
|
||||
public class Packet27WebRTC extends Packet {
|
||||
/**
|
||||
* SDP оффер/answer или ICE кандидат, в зависимости от типа сообщения
|
||||
*/
|
||||
private String sdpOrCandidate;
|
||||
/**
|
||||
* Тип сообщения WebRTC
|
||||
*/
|
||||
private NetworkWebRTCType type;
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
this.type = NetworkWebRTCType.fromCode(stream.readInt8());
|
||||
this.sdpOrCandidate = stream.readString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream steram = new Stream();
|
||||
steram.writeInt16(this.packetId);
|
||||
steram.writeInt8(this.type.getCode());
|
||||
steram.writeString(this.sdpOrCandidate);
|
||||
return steram;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить SDP оффер/answer или ICE кандидат, в зависимости от типа сообщения
|
||||
* @return SDP оффер/answer или ICE кандидат
|
||||
*/
|
||||
public String getSdpOrCandidate() {
|
||||
return sdpOrCandidate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить тип сообщения WebRTC, который указывает на то, является ли это оффером, ответом на оффер или ICE кандидатом
|
||||
* @return тип сообщения WebRTC
|
||||
*/
|
||||
public NetworkWebRTCType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить SDP оффер/answer или ICE кандидат, в зависимости от типа сообщения
|
||||
* @param sdpOrCandidate SDP оффер/answer или ICE кандидат
|
||||
*/
|
||||
public void setSdpOrCandidate(String sdpOrCandidate) {
|
||||
this.sdpOrCandidate = sdpOrCandidate;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить тип сообщения WebRTC, который указывает на то, является ли это оффером, ответом на оффер или ICE кандидатом
|
||||
* @param type тип сообщения WebRTC
|
||||
*/
|
||||
public void setType(NetworkWebRTCType type) {
|
||||
this.type = type;
|
||||
}
|
||||
}
|
||||
@@ -1,58 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import io.g365sfu.webrtc.RTCIceServer;
|
||||
import io.orprotocol.Stream;
|
||||
import io.orprotocol.packet.Packet;
|
||||
|
||||
public class Packet28IceServers extends Packet {
|
||||
|
||||
private List<RTCIceServer> iceServers;
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
int count = stream.readInt16();
|
||||
this.iceServers = new ArrayList<>();
|
||||
for (int i = 0; i < count; i++) {
|
||||
String url = stream.readString();
|
||||
String username = stream.readString();
|
||||
String credential = stream.readString();
|
||||
String transport = stream.readString();
|
||||
RTCIceServer iceServer = new RTCIceServer(url, username, credential, transport);
|
||||
iceServers.add(iceServer);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream stream = new Stream();
|
||||
stream.writeInt16(this.packetId);
|
||||
stream.writeInt16(iceServers.size());
|
||||
for (RTCIceServer iceServer : iceServers) {
|
||||
stream.writeString(iceServer.getUrl());
|
||||
stream.writeString(iceServer.getUsername());
|
||||
stream.writeString(iceServer.getCredential());
|
||||
stream.writeString(iceServer.getTransport());
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получить список серверов ICE, которые могут быть использованы для обмена кандидатами между участниками звонка через сервер SFU.
|
||||
* @return список серверов ICE, которые могут быть использованы для обмена кандидатами между участниками звонка через сервер SFU.
|
||||
*/
|
||||
public List<RTCIceServer> getIceServers() {
|
||||
return iceServers;
|
||||
}
|
||||
|
||||
/**
|
||||
* Установить список серверов ICE, которые могут быть использованы для обмена кандидатами между участниками звонка через сервер SFU.
|
||||
* @param iceServers список серверов ICE, которые могут быть использованы для обмена кандидатами между участниками звонка через сервер SFU.
|
||||
*/
|
||||
public void setIceServers(List<RTCIceServer> iceServers) {
|
||||
this.iceServers = iceServers;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,42 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import im.rosetta.packet.runtime.ResultCode;
|
||||
|
||||
import io.orprotocol.Stream;
|
||||
import io.orprotocol.packet.Packet;
|
||||
|
||||
public class Packet2Result extends Packet {
|
||||
|
||||
private ResultCode resultCode;
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
this.resultCode = ResultCode.fromCode(stream.readInt16());
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream stream = new Stream();
|
||||
stream.writeInt16(this.packetId);
|
||||
stream.writeInt16(this.resultCode.getCode());
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получает код результата операции
|
||||
* @return код результата
|
||||
*/
|
||||
public ResultCode getResultCode() {
|
||||
return this.resultCode;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает код результата операции
|
||||
* @param resultCode код результата
|
||||
*/
|
||||
public void setResultCode(ResultCode resultCode) {
|
||||
this.resultCode = resultCode;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
@@ -1,98 +0,0 @@
|
||||
package im.rosetta.packet;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import im.rosetta.packet.runtime.SearchInfo;
|
||||
|
||||
import io.orprotocol.Stream;
|
||||
import io.orprotocol.packet.Packet;
|
||||
|
||||
public class Packet3Search extends Packet {
|
||||
|
||||
@Deprecated(since = "1.1", forRemoval = true)
|
||||
private String privateKey;
|
||||
private String search;
|
||||
private List<SearchInfo> searchInfo;
|
||||
|
||||
@Override
|
||||
public void read(Stream stream) {
|
||||
this.privateKey = stream.readString();
|
||||
this.search = stream.readString();
|
||||
int searchInfoCount = stream.readInt16();
|
||||
this.searchInfo = new ArrayList<>();
|
||||
for (int i = 0; i < searchInfoCount; i++) {
|
||||
SearchInfo info = new SearchInfo();
|
||||
info.readFromStream(stream);
|
||||
this.searchInfo.add(info);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public Stream write() {
|
||||
Stream stream = new Stream();
|
||||
stream.writeInt16(this.packetId);
|
||||
stream.writeString(this.privateKey);
|
||||
stream.writeString(this.search);
|
||||
stream.writeInt16(this.searchInfo.size());
|
||||
for (SearchInfo info : this.searchInfo) {
|
||||
info.writeToStream(stream);
|
||||
}
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получает приватный ключ пользователя
|
||||
* @return приватный ключ
|
||||
* @deprecated с версии сервера 1.1 использование приватных ключей
|
||||
* в протоколе устарело, так как теперь сервер использует Handshake для аутентификации пользователей.
|
||||
*/
|
||||
@Deprecated(since = "1.1", forRemoval = true)
|
||||
public String getPrivateKey() {
|
||||
return this.privateKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает приватный ключ пользователя
|
||||
* @param privateKey приватный ключ
|
||||
* @deprecated с версии сервера 1.1 использование приватных ключей
|
||||
* в протоколе устарело, так как теперь сервер использует Handshake для аутентификации пользователей.
|
||||
*/
|
||||
@Deprecated(since = "1.1", forRemoval = true)
|
||||
public void setPrivateKey(String privateKey) {
|
||||
this.privateKey = privateKey;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получает строку поиска
|
||||
* @return строка поиска
|
||||
*/
|
||||
public String getSearch() {
|
||||
return this.search;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает строку поиска
|
||||
* @param search строка поиска
|
||||
*/
|
||||
public void setSearch(String search) {
|
||||
this.search = search;
|
||||
}
|
||||
|
||||
/**
|
||||
* Получает результаты поиска
|
||||
* @return список результатов
|
||||
*/
|
||||
public List<SearchInfo> getSearchInfos() {
|
||||
return this.searchInfo;
|
||||
}
|
||||
|
||||
/**
|
||||
* Устанавливает результаты поиска
|
||||
* @param searchInfo
|
||||
*/
|
||||
public void setSearchInfos(List<SearchInfo> searchInfos) {
|
||||
this.searchInfo = searchInfos;
|
||||
}
|
||||
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user