Compare commits

..

24 Commits

Author SHA1 Message Date
00ca218c06 Переделаны все Executors под новый протокол, переделаны все слушатели событий под новый протокол 2026-04-19 01:00:07 +02:00
RoyceDa
33582e2730 Начало трансляции сервероного кода к новому протоколу 2026-04-18 17:50:23 +02:00
RoyceDa
068492b56d Обновленеи протокола, убран legacy код, переход на более практичную схему TLV 2026-04-18 17:49:58 +02:00
9432969cb4 Игнорирование отстуствия файлов APNs/FCM при разработке 2026-04-12 23:23:08 +02:00
RoyceDa
f87198c054 Видеосообщения (кружочки) 2026-04-10 17:36:31 +02:00
RoyceDa
58fe3c409d Новый тип вложений - голосовое сообщение
All checks were successful
Build rosetta-wss / build (push) Successful in 1m51s
2026-04-10 17:28:32 +02:00
RoyceDa
bdc44f36f0 Push READ теперь с пустым уведомлением для точного пробуждения
All checks were successful
Build rosetta-wss / build (push) Successful in 1m57s
2026-04-08 22:11:52 +02:00
RoyceDa
145aaf8288 Исправление кика с сервера при гонке с закрытием RTC на SFU
All checks were successful
Build rosetta-wss / build (push) Successful in 1m31s
2026-04-07 15:24:45 +02:00
RoyceDa
ddcd08aeae END_CALL для остальных устройств принявшего звонок пользователя 2026-04-07 15:16:00 +02:00
RoyceDa
435d6fefa8 Защита от подмены src в пакетах 2026-04-07 15:10:27 +02:00
RoyceDa
986cd765d8 Дополнительные комментарии 2026-04-07 14:56:56 +02:00
RoyceDa
a9c4612a72 Исправление недохода END_CALL к вызываемому пользователю если он авторизован 2026-04-07 14:55:39 +02:00
RoyceDa
bc0a64f450 Исправление зависших сессий на сервере при преждевременном RTC close 2026-04-07 14:43:32 +02:00
faaffd86d0 Обновить src/main/java/im/rosetta/service/dispatch/push/dispatchers/VoIPApns.java
All checks were successful
Build rosetta-wss / build (push) Successful in 1m45s
2026-04-05 21:03:41 +00:00
b1d3416684 Обновить src/main/java/im/rosetta/service/dispatch/push/dispatchers/VoIPApns.java
All checks were successful
Build rosetta-wss / build (push) Successful in 2m14s
2026-04-05 14:46:34 +00:00
RoyceDa
7eacaa6298 Расширены коды ошибок
All checks were successful
Build rosetta-wss / build (push) Successful in 3m42s
2026-04-04 18:59:08 +02:00
RoyceDa
76a007ff42 Фикс киков с сервера
All checks were successful
Build rosetta-wss / build (push) Successful in 3m30s
2026-04-04 18:49:39 +02:00
RoyceDa
20dd5933d9 Merge branch 'dev' into main
All checks were successful
Build rosetta-wss / build (push) Successful in 4m14s
2026-04-04 18:35:51 +02:00
RoyceDa
939a4d55f4 Обновление протокола для неавторизованных звонков 2026-04-04 18:31:05 +02:00
RoyceDa
c59687564e Merge branch 'main' of https://git.rosetta.im/Rosetta/rosetta-wss into main
All checks were successful
Build rosetta-wss / build (push) Successful in 1m45s
2026-04-02 18:29:39 +02:00
RoyceDa
9b8d8cd863 Merge branch 'dev' into main 2026-04-02 18:29:36 +02:00
RoyceDa
3c6b2e0e71 Обновление протокола звонков 2026-04-02 18:11:24 +02:00
398b869e59 Методы в SignalPeer без авторизации 2026-04-02 00:31:18 +02:00
69c6bc63b3 DEVELOPMENT_APNS_HOST
All checks were successful
Build rosetta-wss / build (push) Successful in 1m43s
2026-04-01 14:51:05 +00:00
179 changed files with 5700 additions and 3655 deletions

View File

@@ -1,9 +1,10 @@
package im.rosetta; package im.rosetta;
import im.rosetta.calls.CallManager;
import im.rosetta.client.ClientManager; import im.rosetta.client.ClientManager;
import im.rosetta.client.OnlineManager; import im.rosetta.client.OnlineManager;
import im.rosetta.event.EventManager; import im.rosetta.event.EventManager;
import im.rosetta.executors.Executor0Handshake; import im.rosetta.executors.ExecutorHandshake;
import im.rosetta.executors.Executor10RequestUpdate; import im.rosetta.executors.Executor10RequestUpdate;
import im.rosetta.executors.Executor11Typeing; import im.rosetta.executors.Executor11Typeing;
import im.rosetta.executors.Executor15RequestTransport; import im.rosetta.executors.Executor15RequestTransport;
@@ -11,7 +12,7 @@ import im.rosetta.executors.Executor16PushNotification;
import im.rosetta.executors.Executor17GroupCreate; import im.rosetta.executors.Executor17GroupCreate;
import im.rosetta.executors.Executor18GroupInfo; import im.rosetta.executors.Executor18GroupInfo;
import im.rosetta.executors.Executor19GroupInviteInfo; import im.rosetta.executors.Executor19GroupInviteInfo;
import im.rosetta.executors.Executor1UserInfo; import im.rosetta.executors.ExecutorUserInfo;
import im.rosetta.executors.Executor20GroupJoin; import im.rosetta.executors.Executor20GroupJoin;
import im.rosetta.executors.Executor21GroupLeave; import im.rosetta.executors.Executor21GroupLeave;
import im.rosetta.executors.Executor22GroupBan; import im.rosetta.executors.Executor22GroupBan;
@@ -20,8 +21,8 @@ import im.rosetta.executors.Executor25Sync;
import im.rosetta.executors.Executor26SignalPeer; import im.rosetta.executors.Executor26SignalPeer;
import im.rosetta.executors.Executor27WebRTC; import im.rosetta.executors.Executor27WebRTC;
import im.rosetta.executors.Executor28IceServers; import im.rosetta.executors.Executor28IceServers;
import im.rosetta.executors.Executor3Search; import im.rosetta.executors.ExecutorSearch;
import im.rosetta.executors.Executor4OnlineState; import im.rosetta.executors.ExecutorOnlineState;
import im.rosetta.executors.Executor6Message; import im.rosetta.executors.Executor6Message;
import im.rosetta.executors.Executor7Read; import im.rosetta.executors.Executor7Read;
import im.rosetta.listeners.DeviceListListener; import im.rosetta.listeners.DeviceListListener;
@@ -32,32 +33,7 @@ import im.rosetta.listeners.ServerStopListener;
import im.rosetta.logger.Logger; import im.rosetta.logger.Logger;
import im.rosetta.logger.enums.Color; import im.rosetta.logger.enums.Color;
import im.rosetta.logger.enums.LogLevel; import im.rosetta.logger.enums.LogLevel;
import im.rosetta.packet.Packet0Handshake; import im.rosetta.network.RccGeneratedPacketRegistry;
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.service.services.BufferCleanupService; import im.rosetta.service.services.BufferCleanupService;
import im.rosetta.service.services.ForwardUnitService; import im.rosetta.service.services.ForwardUnitService;
import io.orprotocol.Server; import io.orprotocol.Server;
@@ -82,6 +58,7 @@ public class Boot {
private OnlineManager onlineManager; private OnlineManager onlineManager;
private BufferCleanupService bufferCleanupService; private BufferCleanupService bufferCleanupService;
private ForwardUnitService forwardUnitService; private ForwardUnitService forwardUnitService;
private CallManager callManager;
/** /**
* Конструктор по умолчанию, использует порт 3000 для сервера * Конструктор по умолчанию, использует порт 3000 для сервера
@@ -104,7 +81,8 @@ public class Boot {
port, port,
30 30
), packetManager, this.serverAdapter); ), packetManager, this.serverAdapter);
this.clientManager = new ClientManager(server); this.clientManager = new ClientManager(this.server);
this.callManager = new CallManager(this.clientManager);
/** /**
* Каждые сколько дней будет очищаться буфер (это влияет на синхронизацию сообщений, так * Каждые сколько дней будет очищаться буфер (это влияет на синхронизацию сообщений, так
* как при синхронизации клиент запрашивает пакеты из буфера за последние 7 дней, если этот параметр будет меньше, * как при синхронизации клиент запрашивает пакеты из буфера за последние 7 дней, если этот параметр будет меньше,
@@ -113,7 +91,7 @@ public class Boot {
int cleanupEveryDays = System.getenv("BUFFER_CLEANUP_DAYS") != null ? int cleanupEveryDays = System.getenv("BUFFER_CLEANUP_DAYS") != null ?
Integer.parseInt(System.getenv("BUFFER_CLEANUP_DAYS")) : 7; Integer.parseInt(System.getenv("BUFFER_CLEANUP_DAYS")) : 7;
this.bufferCleanupService = new BufferCleanupService(cleanupEveryDays, this.logger); this.bufferCleanupService = new BufferCleanupService(cleanupEveryDays, this.logger);
this.forwardUnitService = new ForwardUnitService(this.logger, this.clientManager); this.forwardUnitService = new ForwardUnitService(this.logger, this.clientManager, this.callManager);
} }
/** /**
@@ -155,7 +133,7 @@ public class Boot {
public Boot bootstrap() { public Boot bootstrap() {
try{ try{
this.server.start(); this.server.start();
this.registerAllPackets(); RccGeneratedPacketRegistry.registerAll(this.packetManager);
this.registerAllExecutors(); this.registerAllExecutors();
this.registerAllEvents(); this.registerAllEvents();
this.printBootMessage(); this.printBootMessage();
@@ -177,43 +155,11 @@ public class Boot {
this.eventManager.registerListener(new DeviceListListener(this.clientManager)); 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() { private void registerAllExecutors() {
this.packetManager.registerExecutor(0, new Executor0Handshake(this.eventManager, this.clientManager, this.packetManager)); this.packetManager.registerExecutor(0, new ExecutorHandshake(this.eventManager, this.clientManager, this.packetManager));
this.packetManager.registerExecutor(1, new Executor1UserInfo()); this.packetManager.registerExecutor(1, new ExecutorUserInfo());
this.packetManager.registerExecutor(3, new Executor3Search(this.clientManager)); this.packetManager.registerExecutor(3, new ExecutorSearch(this.clientManager));
this.packetManager.registerExecutor(4, new Executor4OnlineState(this.onlineManager, this.clientManager)); this.packetManager.registerExecutor(4, new ExecutorOnlineState(this.onlineManager, this.clientManager));
this.packetManager.registerExecutor(6, new Executor6Message(this.clientManager, this.packetManager)); this.packetManager.registerExecutor(6, new Executor6Message(this.clientManager, this.packetManager));
this.packetManager.registerExecutor(7, new Executor7Read(this.clientManager, this.packetManager)); this.packetManager.registerExecutor(7, new Executor7Read(this.clientManager, this.packetManager));
this.packetManager.registerExecutor(10, new Executor10RequestUpdate()); this.packetManager.registerExecutor(10, new Executor10RequestUpdate());
@@ -228,8 +174,8 @@ public class Boot {
this.packetManager.registerExecutor(22, new Executor22GroupBan()); this.packetManager.registerExecutor(22, new Executor22GroupBan());
this.packetManager.registerExecutor(24, new Executor24DeviceResolve(this.clientManager, this.eventManager, this.packetManager)); this.packetManager.registerExecutor(24, new Executor24DeviceResolve(this.clientManager, this.eventManager, this.packetManager));
this.packetManager.registerExecutor(25, new Executor25Sync(this.packetManager)); this.packetManager.registerExecutor(25, new Executor25Sync(this.packetManager));
this.packetManager.registerExecutor(26, new Executor26SignalPeer(this.clientManager, this.forwardUnitService)); this.packetManager.registerExecutor(26, new Executor26SignalPeer(this.clientManager, this.forwardUnitService, this.callManager));
this.packetManager.registerExecutor(27, new Executor27WebRTC(this.forwardUnitService)); this.packetManager.registerExecutor(27, new Executor27WebRTC(this.callManager));
this.packetManager.registerExecutor(28, new Executor28IceServers(this.forwardUnitService)); this.packetManager.registerExecutor(28, new Executor28IceServers(this.forwardUnitService));
} }

View File

@@ -27,7 +27,11 @@ public enum Failures implements BaseFailures {
/** /**
* Слишком много подписок на онлайн статусы * Слишком много подписок на онлайн статусы
*/ */
TOO_MANY_ONLINE_SUBSCRIPTIONS(3010); TOO_MANY_ONLINE_SUBSCRIPTIONS(3010),
/**
* Нет сессии звонка
*/
NO_CALL_SESSION(3011);
private final int code; private final int code;

View File

@@ -0,0 +1,119 @@
package im.rosetta.calls;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.TimeUnit;
import im.rosetta.client.ClientManager;
import im.rosetta.packet.Packet26SignalPeer;
import im.rosetta.packet.runtime.NetworkSignalType;
import io.g365sfu.Room;
import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client;
import io.orprotocol.packet.Packet;
public class CallManager {
private List<CallSession> callSessions = new ArrayList<>();
private final ScheduledExecutorService scheduler = Executors.newSingleThreadScheduledExecutor();
private static final long RINGING_TIMEOUT = 30 * 1000;
private ClientManager clientManager;
public CallManager(ClientManager clientManager) {
this.clientManager = clientManager;
scheduler.scheduleAtFixedRate(this::cleanupCallSessions, 0, 1, TimeUnit.SECONDS);
}
public void cleanupCallSessions() {
/**
* Такая конструкция нужна для избежания ConcurrentModificationException,
* так как мы не можем удалять элементы из списка, по которому проходим в цикле,
* поэтому мы сначала собираем сессии звонков, которые нужно удалить, а потом
* удаляем их из основного списка
*/
List<CallSession> sessionsToRemove = new ArrayList<>();
for (CallSession session : this.callSessions) {
if (session.shouldRemove()) {
/**
* Отправляем всем в сессии что звонок завершился, так как он устарел, и удаляем сессию из списка активных сессий
*/
Packet26SignalPeer rtout = new Packet26SignalPeer();
rtout.setSignalType(NetworkSignalType.RINGING_TIMEOUT);
Packet26SignalPeer endCallPacket = new Packet26SignalPeer();
endCallPacket.setSignalType(NetworkSignalType.END_CALL);
endCallPacket.setJoinToken(session.getJoinToken());
endCallPacket.setCallId(session.getCallId());
try {
session.sendPacket(rtout, null);
this.sendPacketToRinging(session, endCallPacket);
} catch (ProtocolException e) {
e.printStackTrace();
}
sessionsToRemove.add(session);
}
}
for (CallSession session : sessionsToRemove) {
this.callSessions.remove(session);
}
}
public CallSession createCall(String callId, String joinToken) {
CallSession session = new CallSession(callId, joinToken, RINGING_TIMEOUT);
this.callSessions.add(session);
return session;
}
public CallSession getCallSession(String callId, String joinToken) {
for (CallSession session : this.callSessions) {
if (session.getCallId().equals(callId) && session.getJoinToken().equals(joinToken)) {
return session;
}
}
return null;
}
public CallSession getCallSession(Room room) {
for (CallSession session : this.callSessions) {
if (session.getRoom() != null && session.getRoom().equals(room)) {
return session;
}
}
return null;
}
public boolean isBusy(String publicKey) {
for (CallSession session : this.callSessions) {
if (session.clients.containsKey(publicKey)) {
return true;
}
if(session.ringing.containsKey(publicKey)) {
return true;
}
}
return false;
}
public void sendPacketToRinging(CallSession session, Packet packet) throws ProtocolException {
for (String publicKey : session.ringing.keySet()) {
this.clientManager.sendPacketToAuthorizedPK(publicKey, packet);
}
}
public CallSession getCallSession(Client client) {
for (CallSession session : this.callSessions) {
if (session.clients.containsValue(client)) {
return session;
}
}
return null;
}
public void removeSession(CallSession session) {
this.callSessions.remove(session);
}
}

View File

@@ -0,0 +1,131 @@
package im.rosetta.calls;
import java.util.HashMap;
import io.g365sfu.Room;
import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client;
import io.orprotocol.packet.Packet;
public class CallSession {
public String callId;
public String joinToken;
public Long createdAt;
public Long ringingTimeout;
/**
* Клиенты которым сейчас идет дозвон (публичные ключи)
* Клиенты в этом списке не могут принимать другие звонки, так как они уже заняты дозвоном,
* но они еще не в звонке, так как не приняли звонок
*
* Клиенты удаляются из этого списка, когда они принимают звонок или отклоняют его,
* тогда они либо переходят в звонок, либо становятся свободными для других звонков
* pk -> время начала дозвона (timestamp в миллисекундах)
*/
public HashMap<String, Long> ringing;
/**
* Клиенты, которые уже приняли звонок и находятся в звонке (публичные ключи) и их сокеты
* pk -> client
*/
public HashMap<String, Client> clients;
/**
* Если звонок активен у него появляется комната, иначе комната null
*/
public Room room;
public CallSession(String callId, String joinToken, Long ringingTimeout) {
this.callId = callId;
this.joinToken = joinToken;
this.clients = new HashMap<>();
this.ringing = new HashMap<>();
this.createdAt = System.currentTimeMillis();
this.ringingTimeout = ringingTimeout;
}
public void joinCall(String publicKey, Client client) {
if(this.ringing.containsKey(publicKey)) {
this.ringing.remove(publicKey);
}
this.clients.put(publicKey, client);
}
/**
* Проверяет, может ли этот публичный ключ выполнять какие-либо действия в рамках этой сессии звонка,
* чтобы не допустить выполнение действий от посторонних публичных ключей, которые не участвуют в звонке
* @param publicKey Публичный ключ для проверки
* @return true, если этот публичный ключ может выполнять действия в рамках этой сессии звонка, false иначе
*/
public boolean isValidSource(String publicKey) {
return this.ringing.containsKey(publicKey) || this.clients.containsKey(publicKey);
}
/**
* Получаем публичный ключ клиента по его сокету, чтобы понимать, кто отправляет сигналы в рамках звонка
* @param client Сокет клиента, для которого нужно получить публичный ключ
* @return Публичный ключ клиента, или null если клиент не найден в сессии звонка
*/
public String getPublicKey(Client client) {
for (String publicKey : this.clients.keySet()) {
if (this.clients.get(publicKey).equals(client)) {
return publicKey;
}
}
return null;
}
public String getCallId() {
return this.callId;
}
public String getJoinToken() {
return this.joinToken;
}
public void leaveCall(String publicKey) {
if(this.clients.containsKey(publicKey)) {
this.clients.remove(publicKey);
}
if(this.ringing.containsKey(publicKey)) {
this.ringing.remove(publicKey);
}
}
public void addRinging(String publicKey) {
this.ringing.put(publicKey, System.currentTimeMillis());
}
public void setRoom(Room room) {
this.room = room;
}
public Room getRoom() {
return this.room;
}
/**
* Отправляем пакет всем участникам звонка, кроме исключенного клиента (обычно отправителя)
* @param packet Пакет для отправки
* @param excludeClient Клиент, которому не нужно отправлять пакет (обычно отправитель)
* @throws ProtocolException Если произошла ошибка при отправке пакета клиенту
*/
public void sendPacket(Packet packet, Client excludeClient) throws ProtocolException {
for (Client client : this.clients.values()) {
if (!client.equals(excludeClient)) {
client.send(packet);
}
}
}
/**
* Проверяем, нужно ли удалять сессию звонка.
* Сессию звонка нужно удалять, если в ней меньше 2 клиентов и при этом нет клиентов в состоянии дозвона,
* или если сессия была создана более 1 минуты назад, так как это значит, что клиенты не ответили на звонок и он устарел
* @return true, если сессию звонка нужно удалять, false иначе
*/
public boolean shouldRemove() {
return this.clients.size() <= 1 && (this.ringing.size() == 0 || System.currentTimeMillis() - this.createdAt > this.ringingTimeout);
}
}

View File

@@ -56,9 +56,10 @@ public class ClientManager {
* Отправить пакет ВСЕМ АВТОРИЗОВАННЫМ клиентам с публичным ключом publicKey * Отправить пакет ВСЕМ АВТОРИЗОВАННЫМ клиентам с публичным ключом publicKey
* @param publicKey публичный ключ получателя * @param publicKey публичный ключ получателя
* @param packet пакет для отправки * @param packet пакет для отправки
* @param exclude клиент, который не должен получать этот пакет, может быть null
* @throws ProtocolException если произошла ошибка при отправке пакета клиенту * @throws ProtocolException если произошла ошибка при отправке пакета клиенту
*/ */
public void sendPacketToAuthorizedPK(String publicKey, Packet packet) throws ProtocolException { public void sendPacketToAuthorizedPK(String publicKey, Packet packet, Client exclude) throws ProtocolException {
Set<Client> clients = this.clientIndexer.getClients(ECIAuthentificate.class, "publicKey", publicKey); Set<Client> clients = this.clientIndexer.getClients(ECIAuthentificate.class, "publicKey", publicKey);
if(clients == null){ if(clients == null){
/** /**
@@ -77,12 +78,55 @@ public class ClientManager {
continue; continue;
} }
/** /**
* Отправляем пакет каждому клиенту с таким публичным ключом (то есть всем его авторизованным сессиям/устройствам) * Отправляем пакет каждому клиенту с таким публичным ключом (то есть всем его авторизованным сессиям/устройствам),
* исключая клиента exclude
*/ */
if(exclude != null && client.equals(exclude)){
/**
* Этот клиент является исключением, он не должен получать этот пакет
*/
continue;
}
client.send(packet); client.send(packet);
} }
} }
/**
* Отправить пакет ВСЕМ АВТОРИЗОВАННЫМ клиентам с публичным ключом publicKey
* @param publicKey публичный ключ получателя
* @param packet пакет для отправки
* @throws ProtocolException если произошла ошибка при отправке пакета клиенту
*/
public void sendPacketToAuthorizedPK(String publicKey, Packet packet) throws ProtocolException {
this.sendPacketToAuthorizedPK(publicKey, packet, null);
}
/**
* Отправить пакет всем клиентам с публичными ключами из списка publicKeys
* @param publicKeys список публичных ключей получателей
* @param packet пакет для отправки
* @param exclude клиент, который не должен получать этот пакет, может быть null
* @throws ProtocolException если произошла ошибка при отправке пакета клиенту
*/
public void sendPacketToAuthorizedPK(List<String> publicKeys, Packet packet, Client exclude) throws ProtocolException {
for(String publicKey : publicKeys){
this.sendPacketToAuthorizedPK(publicKey, packet, exclude);
}
}
/**
* Отправить пакет всем клиентам с публичными ключами из списка publicKeys
* @param publicKeys список публичных ключей получателей
* @param packet пакет для отправки
* @throws ProtocolException если произошла ошибка при отправке пакета клиенту
*/
public void sendPacketToAuthorizedPK(List<String> publicKeys, Packet packet) throws ProtocolException {
for(String publicKey : publicKeys){
this.sendPacketToAuthorizedPK(publicKey, packet, null);
}
}
/** /**
* Отправить пакет всем клиентам с публичными ключом как у client, кроме клиента client, который является отправителем и не должен получать этот пакет * Отправить пакет всем клиентам с публичными ключом как у client, кроме клиента client, который является отправителем и не должен получать этот пакет
* @param client клиент * @param client клиент
@@ -111,18 +155,6 @@ public class ClientManager {
} }
} }
/**
* Отправить пакет всем клиентам с публичными ключами из списка publicKeys
* @param publicKeys список публичных ключей получателей
* @param packet пакет для отправки
* @throws ProtocolException если произошла ошибка при отправке пакета клиенту
*/
public void sendPacketToAuthorizedPK(List<String> publicKeys, Packet packet) throws ProtocolException {
for(String publicKey : publicKeys){
this.sendPacketToAuthorizedPK(publicKey, packet);
}
}
/** /**
* Получить список клиентов по публичному ключу (get PublicKey clients), могут быть неавторизованные клиенты * Получить список клиентов по публичному ключу (get PublicKey clients), могут быть неавторизованные клиенты
* @param publicKey публичный ключ клиента * @param publicKey публичный ключ клиента

View File

@@ -3,8 +3,7 @@ package im.rosetta.client.tags;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import im.rosetta.packet.runtime.HandshakeStage; import im.rosetta.network.enums.HandshakeStage;
import io.orprotocol.client.ECITag; import io.orprotocol.client.ECITag;
/** /**

View File

@@ -1,7 +1,7 @@
package im.rosetta.database.entity; package im.rosetta.database.entity;
import im.rosetta.database.CreateUpdateEntity; import im.rosetta.database.CreateUpdateEntity;
import im.rosetta.packet.runtime.TokenType; import im.rosetta.network.enums.TokenType;
import jakarta.persistence.Column; import jakarta.persistence.Column;
import jakarta.persistence.Entity; import jakarta.persistence.Entity;
import jakarta.persistence.EnumType; import jakarta.persistence.EnumType;

View File

@@ -1,97 +0,0 @@
package im.rosetta.executors;
import java.util.HashMap;
import java.util.UUID;
import im.rosetta.Failures;
import im.rosetta.client.ClientManager;
import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.packet.Packet26SignalPeer;
import im.rosetta.packet.runtime.NetworkSignalType;
import im.rosetta.service.dispatch.push.PushNotifyDispatcher;
import im.rosetta.service.dispatch.runtime.PushType;
import im.rosetta.service.services.ForwardUnitService;
import io.g365sfu.Room;
import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor;
/**
* Используется в Peer To Peer звонках, в групповых звонках другой сигналинг
*/
public class Executor26SignalPeer extends PacketExecutor<Packet26SignalPeer> {
private ClientManager clientManager;
private ForwardUnitService fus;
private PushNotifyDispatcher pushNotifyDispatcher = new PushNotifyDispatcher();
public Executor26SignalPeer(ClientManager clientManager, ForwardUnitService fus) {
this.clientManager = clientManager;
this.fus = fus;
}
@Override
public void onPacketReceived(Packet26SignalPeer packet, Client client) throws Exception, ProtocolException {
String src = packet.getSrc();
String dst = packet.getDst();
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
if (eciAuthentificate == null || !eciAuthentificate.hasAuthorized()) {
/**
* Если клиент не авторизован, то мы не будем обрабатывать его сигналы на анициализацию звонка
* и просто отключим его от сервера.
*/
client.disconnect(Failures.HANDSHAKE_NOT_COMPLETED);
return;
}
if(!src.equals(eciAuthentificate.getPublicKey())) {
/**
* Если src в пакете не совпадает с авторизованным PK клиента, то это может означать, что клиент пытается
* отправить сигнал от другого пользователя, отключаем его от сервера.
*/
client.disconnect(Failures.DATA_MISSMATCH);
return;
}
NetworkSignalType type = packet.getSignalType();
if(type == NetworkSignalType.CALL) {
/**
* Инициируется звонок от src к dst, проверяем, что dst не занят другим звонком, если занят, то отправляем сигнал END_CALL_BECAUSE_BUSY обратно src
*/
Room room = this.fus.getRoomByParticipantId(packet.getDst());
if(room != null) {
/**
* Получатель сигнала уже находится в другой комнате, значит он занят другим звонком, отправляем сигнал END_CALL_BECAUSE_BUSY обратно src
*/
Packet26SignalPeer responsePacket = new Packet26SignalPeer();
responsePacket.setSignalType(NetworkSignalType.END_CALL_BECAUSE_BUSY);
this.clientManager.sendPacketToAuthorizedPK(packet.getSrc(), responsePacket);
return;
}
/**
* Получатель сигнала не занят, отправляем ему пуш уведомление о входящем звонке и сигнал CALL для инициализации звонка
*/
pushNotifyDispatcher.sendPush(dst, new HashMap<>(){{
put("type", PushType.CALL);
put("dialog", src);
put("callId", UUID.randomUUID().toString());
}});
}
if(type == NetworkSignalType.CREATE_ROOM){
/**
* Создается комната для звонка
*/
Room room = this.fus.createRoom();
room.addParticipant(packet.getSrc());
room.addParticipant(packet.getDst());
packet.setRoomId(room.getRoomId());
/**
* Результат создания комнаты транслируем обоим участникам, чтобы они могли начать обмен WebRTC SDP, и тд
*/
this.clientManager.sendPacketToAuthorizedPK(packet.getSrc(), packet);
this.clientManager.sendPacketToAuthorizedPK(packet.getDst(), packet);
return;
}
this.clientManager.sendPacketToAuthorizedPK(packet.getDst(), packet);
}
}

View File

@@ -1,73 +0,0 @@
package im.rosetta.executors;
import im.rosetta.Failures;
import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.packet.Packet27WebRTC;
import im.rosetta.packet.runtime.NetworkWebRTCType;
import im.rosetta.service.services.ForwardUnitService;
import io.g365sfu.Room;
import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor;
public class Executor27WebRTC extends PacketExecutor<Packet27WebRTC> {
private ForwardUnitService fus;
public Executor27WebRTC(ForwardUnitService fus) {
this.fus = fus;
}
@Override
public void onPacketReceived(Packet27WebRTC packet, Client client) throws Exception, ProtocolException {
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()) {
/**
* Если клиент не авторизован, то мы не будем обрабатывать его сигналы на инициализацию звонка
* и просто отключим его от сервера.
*/
client.disconnect(Failures.HANDSHAKE_NOT_COMPLETED);
return;
}
String publicKey = eciAuthentificate.getPublicKey();
/**
* Так как в комнатах Participants это публичные ключи пользователей, то мы можем
* найти комнату, в которой находится пользователь, по его публичному ключу
*/
Room room = this.fus.getRoomByParticipantId(publicKey);
if(room == null) {
/**
* Если комната не найдена, то мы не будем обрабатывать сигналы для звонка
* и просто отключим клиента от сервера.
*/
client.disconnect(Failures.DATA_MISSMATCH);
return;
}
NetworkWebRTCType type = packet.getType();
if(type == NetworkWebRTCType.OFFER) {
/**
* Если это OFFER, то отправляем OFFER на сервер SFU,
* который отвечает за эту комнату, чтобы он транслировал его всем участникам комнаты, кроме отправителя
*/
room.sdpOffer(publicKey, packet.getSdpOrCandidate());
}
if(type == NetworkWebRTCType.ICE_CANDIDATE) {
/**
* Если это ICE кандидат, то отправляем его на сервер SFU,
* который отвечает за эту комнату, чтобы он транслировал его всем участникам комнаты, кроме отправителя
*/
room.iceCandidate(publicKey, packet.getSdpOrCandidate());
}
if(type == NetworkWebRTCType.ANSWER) {
/**
* Если это ANSWER, то отправляем его на сервер SFU,
* который отвечает за эту комнату, чтобы он транслировал его всем участникам комнаты, кроме отправителя
*/
room.sdpAnswer(publicKey, packet.getSdpOrCandidate());
}
}
}

View File

@@ -1,39 +0,0 @@
package im.rosetta.executors;
import java.util.ArrayList;
import im.rosetta.Failures;
import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.packet.Packet28IceServers;
import im.rosetta.service.services.ForwardUnitService;
import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor;
public class Executor28IceServers extends PacketExecutor<Packet28IceServers> {
private ForwardUnitService fus;
public Executor28IceServers(ForwardUnitService fus) {
this.fus = fus;
}
@Override
public void onPacketReceived(Packet28IceServers packet, Client client) throws Exception, ProtocolException {
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()) {
/**
* Если клиент не авторизован, то мы не будем обрабатывать его запрос на получение ICE серверов
* и просто отключим его от сервера.
*/
client.disconnect(Failures.HANDSHAKE_NOT_COMPLETED);
return;
}
/**
* Берем TURN сервера и отправляем их клиенту
*/
packet.setIceServers(new ArrayList<>(this.fus.getTurnServers()));
client.send(packet);
}
}

View File

@@ -11,10 +11,10 @@ import im.rosetta.database.repository.BufferRepository;
import im.rosetta.database.repository.DeviceRepository; import im.rosetta.database.repository.DeviceRepository;
import im.rosetta.event.EventManager; import im.rosetta.event.EventManager;
import im.rosetta.event.events.handshake.HandshakeCompletedEvent; import im.rosetta.event.events.handshake.HandshakeCompletedEvent;
import im.rosetta.packet.Packet0Handshake; import im.rosetta.network.enums.DeviceSolution;
import im.rosetta.packet.Packet24DeviceResolve; import im.rosetta.network.enums.HandshakeStage;
import im.rosetta.packet.runtime.DeviceSolution; import im.rosetta.network.packet.PacketDeviceResolve;
import im.rosetta.packet.runtime.HandshakeStage; import im.rosetta.network.packet.PacketHandshake;
import im.rosetta.service.dispatch.DeviceDispatcher; import im.rosetta.service.dispatch.DeviceDispatcher;
import im.rosetta.service.services.BufferService; import im.rosetta.service.services.BufferService;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
@@ -22,7 +22,7 @@ import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor; import io.orprotocol.packet.PacketExecutor;
import io.orprotocol.packet.PacketManager; import io.orprotocol.packet.PacketManager;
public class Executor24DeviceResolve extends PacketExecutor<Packet24DeviceResolve> { public class ExecutorDeviceResolve extends PacketExecutor<PacketDeviceResolve> {
private final ClientManager clientManager; private final ClientManager clientManager;
private final EventManager eventManager; private final EventManager eventManager;
@@ -31,7 +31,7 @@ public class Executor24DeviceResolve extends PacketExecutor<Packet24DeviceResolv
private final BufferRepository bufferRepository = new BufferRepository(); private final BufferRepository bufferRepository = new BufferRepository();
private final BufferService bufferService; private final BufferService bufferService;
public Executor24DeviceResolve(ClientManager clientManager, EventManager eventManager, PacketManager packetManager) { public ExecutorDeviceResolve(ClientManager clientManager, EventManager eventManager, PacketManager packetManager) {
this.clientManager = clientManager; this.clientManager = clientManager;
this.eventManager = eventManager; this.eventManager = eventManager;
this.deviceDispatcher = new DeviceDispatcher(clientManager); this.deviceDispatcher = new DeviceDispatcher(clientManager);
@@ -39,7 +39,7 @@ public class Executor24DeviceResolve extends PacketExecutor<Packet24DeviceResolv
} }
@Override @Override
public void onPacketReceived(Packet24DeviceResolve packet, Client client) throws Exception, ProtocolException { public void onPacketReceived(PacketDeviceResolve packet, Client client) throws Exception, ProtocolException {
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class); ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
if (eciAuthentificate == null || !eciAuthentificate.hasAuthorized()) { if (eciAuthentificate == null || !eciAuthentificate.hasAuthorized()) {
/** /**
@@ -81,7 +81,7 @@ public class Executor24DeviceResolve extends PacketExecutor<Packet24DeviceResolv
* а так же исправить баг, когда при подключении первого устройства показывалось уведомление * а так же исправить баг, когда при подключении первого устройства показывалось уведомление
* о новом входе. * о новом входе.
* *
* 9 ID пакета - Packet9DeviceNew * 9 ID пакета - PacketDeviceNew
*/ */
this.bufferService.deletePacketsFromBuffer(eciAuthentificate.getPublicKey(), 9, 0); this.bufferService.deletePacketsFromBuffer(eciAuthentificate.getPublicKey(), 9, 0);
@@ -95,7 +95,7 @@ public class Executor24DeviceResolve extends PacketExecutor<Packet24DeviceResolv
* Отправляем этому устройству пакет с успешным хэндшейком, чтобы клиент понял, * Отправляем этому устройству пакет с успешным хэндшейком, чтобы клиент понял,
* что устройство разрешено и мог продолжать работу * что устройство разрешено и мог продолжать работу
*/ */
Packet0Handshake handshake = new Packet0Handshake(); PacketHandshake handshake = new PacketHandshake();
handshake.setHandshakeStage(HandshakeStage.COMPLETED); handshake.setHandshakeStage(HandshakeStage.COMPLETED);
handshake.setDeviceId(""); handshake.setDeviceId("");
handshake.setDeviceName(""); handshake.setDeviceName("");
@@ -131,7 +131,7 @@ public class Executor24DeviceResolve extends PacketExecutor<Packet24DeviceResolv
* а так же исправить баг, когда при подключении первого устройства показывалось уведомление * а так же исправить баг, когда при подключении первого устройства показывалось уведомление
* о новом входе. * о новом входе.
* *
* 9 ID пакета - Packet9DeviceNew * 9 ID пакета - PacketDeviceNew
*/ */
this.bufferService.deletePacketsFromBuffer(eciAuthentificate.getPublicKey(), 9, 0); this.bufferService.deletePacketsFromBuffer(eciAuthentificate.getPublicKey(), 9, 0);
break; break;

View File

@@ -6,19 +6,18 @@ import im.rosetta.Failures;
import im.rosetta.client.tags.ECIAuthentificate; import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.database.entity.Group; import im.rosetta.database.entity.Group;
import im.rosetta.database.repository.GroupRepository; import im.rosetta.database.repository.GroupRepository;
import im.rosetta.packet.Packet18GroupInfo; import im.rosetta.network.packet.PacketGroupBan;
import im.rosetta.packet.Packet22GroupBan; import im.rosetta.network.packet.PacketGroupInfo;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client; import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor; import io.orprotocol.packet.PacketExecutor;
public class Executor22GroupBan extends PacketExecutor<Packet22GroupBan> { public class ExecutorGroupBan extends PacketExecutor<PacketGroupBan> {
private final GroupRepository groupRepository = new GroupRepository(); private final GroupRepository groupRepository = new GroupRepository();
@Override @Override
public void onPacketReceived(Packet22GroupBan packet, Client client) throws Exception, ProtocolException { public void onPacketReceived(PacketGroupBan packet, Client client) throws Exception, ProtocolException {
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class); ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()){ if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()){
/** /**
@@ -69,7 +68,7 @@ public class Executor22GroupBan extends PacketExecutor<Packet22GroupBan> {
* Отправляем клиенту новый Packet18GroupInfo, чтобы он обновил информацию о группе, * Отправляем клиенту новый Packet18GroupInfo, чтобы он обновил информацию о группе,
* например, удалил участника из списка участников * например, удалил участника из списка участников
*/ */
Packet18GroupInfo groupInfoPacket = new Packet18GroupInfo(); PacketGroupInfo groupInfoPacket = new PacketGroupInfo();
groupInfoPacket.setGroupId(groupId); groupInfoPacket.setGroupId(groupId);
groupInfoPacket.setMembersPKs(group.getMembersPublicKeys()); groupInfoPacket.setMembersPKs(group.getMembersPublicKeys());
client.send(groupInfoPacket); client.send(groupInfoPacket);

View File

@@ -3,19 +3,19 @@ package im.rosetta.executors;
import im.rosetta.Failures; import im.rosetta.Failures;
import im.rosetta.client.tags.ECIAuthentificate; import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.database.repository.GroupRepository; import im.rosetta.database.repository.GroupRepository;
import im.rosetta.packet.Packet17GroupCreate; import im.rosetta.network.packet.PacketGroupCreate;
import im.rosetta.util.RandomUtil; import im.rosetta.util.RandomUtil;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client; import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor; import io.orprotocol.packet.PacketExecutor;
public class Executor17GroupCreate extends PacketExecutor<Packet17GroupCreate> { public class ExecutorGroupCreate extends PacketExecutor<PacketGroupCreate> {
private final GroupRepository groupRepository = new GroupRepository(); private final GroupRepository groupRepository = new GroupRepository();
@Override @Override
public void onPacketReceived(Packet17GroupCreate packet, Client client) throws Exception, ProtocolException { public void onPacketReceived(PacketGroupCreate packet, Client client) throws Exception, ProtocolException {
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class); ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()){ if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()){
/** /**

View File

@@ -6,18 +6,17 @@ import im.rosetta.Failures;
import im.rosetta.client.tags.ECIAuthentificate; import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.database.entity.Group; import im.rosetta.database.entity.Group;
import im.rosetta.database.repository.GroupRepository; import im.rosetta.database.repository.GroupRepository;
import im.rosetta.packet.Packet18GroupInfo; import im.rosetta.network.packet.PacketGroupInfo;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client; import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor; import io.orprotocol.packet.PacketExecutor;
public class Executor18GroupInfo extends PacketExecutor<Packet18GroupInfo> { public class ExecutorGroupInfo extends PacketExecutor<PacketGroupInfo> {
private final GroupRepository groupRepository = new GroupRepository(); private final GroupRepository groupRepository = new GroupRepository();
@Override @Override
public void onPacketReceived(Packet18GroupInfo packet, Client client) throws Exception, ProtocolException { public void onPacketReceived(PacketGroupInfo packet, Client client) throws Exception, ProtocolException {
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class); ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()){ if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()){
/** /**

View File

@@ -4,19 +4,18 @@ import im.rosetta.Failures;
import im.rosetta.client.tags.ECIAuthentificate; import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.database.entity.Group; import im.rosetta.database.entity.Group;
import im.rosetta.database.repository.GroupRepository; import im.rosetta.database.repository.GroupRepository;
import im.rosetta.packet.Packet19GroupInviteInfo; import im.rosetta.network.enums.GroupStatus;
import im.rosetta.packet.runtime.NetworkGroupStatus; import im.rosetta.network.packet.PacketGroupInviteInfo;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client; import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor; import io.orprotocol.packet.PacketExecutor;
public class Executor19GroupInviteInfo extends PacketExecutor<Packet19GroupInviteInfo> { public class ExecutorGroupInviteInfo extends PacketExecutor<PacketGroupInviteInfo> {
private final GroupRepository groupRepository = new GroupRepository(); private final GroupRepository groupRepository = new GroupRepository();
@Override @Override
public void onPacketReceived(Packet19GroupInviteInfo packet, Client client) throws Exception, ProtocolException { public void onPacketReceived(PacketGroupInviteInfo packet, Client client) throws Exception, ProtocolException {
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class); ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()){ if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()){
/** /**
@@ -31,7 +30,7 @@ public class Executor19GroupInviteInfo extends PacketExecutor<Packet19GroupInvit
/** /**
* Группы не существует, возвращаем клиенту статус INVALID * Группы не существует, возвращаем клиенту статус INVALID
*/ */
packet.setStatus(NetworkGroupStatus.INVALID); packet.setStatus(GroupStatus.INVALID);
client.send(packet); client.send(packet);
return; return;
} }
@@ -39,7 +38,7 @@ public class Executor19GroupInviteInfo extends PacketExecutor<Packet19GroupInvit
/** /**
* Клиент забанен в группе, возвращаем клиенту статус BANNED * Клиент забанен в группе, возвращаем клиенту статус BANNED
*/ */
packet.setStatus(NetworkGroupStatus.BANNED); packet.setStatus(GroupStatus.BANNED);
client.send(packet); client.send(packet);
return; return;
} }
@@ -50,7 +49,7 @@ public class Executor19GroupInviteInfo extends PacketExecutor<Packet19GroupInvit
int membersCount = group.getMembersPublicKeys().size(); int membersCount = group.getMembersPublicKeys().size();
boolean isMember = group.getMembersPublicKeys().contains(eciAuthentificate.getPublicKey()); boolean isMember = group.getMembersPublicKeys().contains(eciAuthentificate.getPublicKey());
packet.setMembersCount(membersCount); packet.setMembersCount(membersCount);
packet.setStatus(isMember ? NetworkGroupStatus.JOINED : NetworkGroupStatus.NOT_JOINED); packet.setStatus(isMember ? GroupStatus.JOINED : GroupStatus.NOT_JOINED);
client.send(packet); client.send(packet);
} }

View File

@@ -5,26 +5,26 @@ import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.database.entity.Group; import im.rosetta.database.entity.Group;
import im.rosetta.database.repository.BufferRepository; import im.rosetta.database.repository.BufferRepository;
import im.rosetta.database.repository.GroupRepository; import im.rosetta.database.repository.GroupRepository;
import im.rosetta.packet.Packet20GroupJoin; import im.rosetta.network.enums.GroupStatus;
import im.rosetta.packet.runtime.NetworkGroupStatus; import im.rosetta.network.packet.PacketGroupJoin;
import im.rosetta.service.services.BufferService; import im.rosetta.service.services.BufferService;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client; import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor; import io.orprotocol.packet.PacketExecutor;
import io.orprotocol.packet.PacketManager; import io.orprotocol.packet.PacketManager;
public class Executor20GroupJoin extends PacketExecutor<Packet20GroupJoin> { public class ExecutorGroupJoin extends PacketExecutor<PacketGroupJoin> {
private final GroupRepository groupRepository = new GroupRepository(); private final GroupRepository groupRepository = new GroupRepository();
private final BufferRepository bufferRepository = new BufferRepository(); private final BufferRepository bufferRepository = new BufferRepository();
private final BufferService bufferService; private final BufferService bufferService;
public Executor20GroupJoin(PacketManager packetManager) { public ExecutorGroupJoin(PacketManager packetManager) {
this.bufferService = new BufferService(bufferRepository, packetManager); this.bufferService = new BufferService(bufferRepository, packetManager);
} }
@Override @Override
public void onPacketReceived(Packet20GroupJoin packet, Client client) throws Exception, ProtocolException { public void onPacketReceived(PacketGroupJoin packet, Client client) throws Exception, ProtocolException {
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class); ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()){ if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()){
/** /**
@@ -39,7 +39,7 @@ public class Executor20GroupJoin extends PacketExecutor<Packet20GroupJoin> {
/** /**
* Группы не существует, возвращаем клиенту статус INVALID * Группы не существует, возвращаем клиенту статус INVALID
*/ */
packet.setStatus(NetworkGroupStatus.INVALID); packet.setStatus(GroupStatus.INVALID);
client.send(packet); client.send(packet);
return; return;
} }
@@ -48,7 +48,7 @@ public class Executor20GroupJoin extends PacketExecutor<Packet20GroupJoin> {
/** /**
* Клиент забанен в группе, возвращаем клиенту статус BANNED * Клиент забанен в группе, возвращаем клиенту статус BANNED
*/ */
packet.setStatus(NetworkGroupStatus.BANNED); packet.setStatus(GroupStatus.BANNED);
client.send(packet); client.send(packet);
return; return;
} }
@@ -57,14 +57,14 @@ public class Executor20GroupJoin extends PacketExecutor<Packet20GroupJoin> {
/** /**
* Клиент уже является участником группы, возвращаем клиенту статус JOINED * Клиент уже является участником группы, возвращаем клиенту статус JOINED
*/ */
packet.setStatus(NetworkGroupStatus.JOINED); packet.setStatus(GroupStatus.JOINED);
client.send(packet); client.send(packet);
return; return;
} }
/** /**
* Все проверки пройдены, клиент может вступить в группу * Все проверки пройдены, клиент может вступить в группу
*/ */
packet.setStatus(NetworkGroupStatus.JOINED); packet.setStatus(GroupStatus.JOINED);
/** /**
* Кладем пакет в буфер для будущей синхронизации * Кладем пакет в буфер для будущей синхронизации
*/ */

View File

@@ -4,7 +4,7 @@ import im.rosetta.Failures;
import im.rosetta.client.tags.ECIAuthentificate; import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.database.entity.Group; import im.rosetta.database.entity.Group;
import im.rosetta.database.repository.GroupRepository; import im.rosetta.database.repository.GroupRepository;
import im.rosetta.packet.Packet21GroupLeave; import im.rosetta.network.packet.PacketGroupLeave;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client; import io.orprotocol.client.Client;
@@ -16,12 +16,12 @@ import io.orprotocol.packet.PacketExecutor;
* чтобы клиентское приложение могло корректно обновить интерфейс, например, удалить группу из списка групп пользователя * чтобы клиентское приложение могло корректно обновить интерфейс, например, удалить группу из списка групп пользователя
* Если клиент является единственным участником группы, то при выходе группа удаляется целиком * Если клиент является единственным участником группы, то при выходе группа удаляется целиком
*/ */
public class Executor21GroupLeave extends PacketExecutor<Packet21GroupLeave> { public class ExecutorGroupLeave extends PacketExecutor<PacketGroupLeave> {
private final GroupRepository groupRepository = new GroupRepository(); private final GroupRepository groupRepository = new GroupRepository();
@Override @Override
public void onPacketReceived(Packet21GroupLeave packet, Client client) throws Exception, ProtocolException { public void onPacketReceived(PacketGroupLeave packet, Client client) throws Exception, ProtocolException {
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class); ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()){ if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()){
/** /**

View File

@@ -13,9 +13,9 @@ import im.rosetta.event.EventManager;
import im.rosetta.event.events.handshake.HandshakeCompletedEvent; import im.rosetta.event.events.handshake.HandshakeCompletedEvent;
import im.rosetta.event.events.handshake.HandshakeDeviceConfirmEvent; import im.rosetta.event.events.handshake.HandshakeDeviceConfirmEvent;
import im.rosetta.event.events.handshake.HandshakeFailedEvent; import im.rosetta.event.events.handshake.HandshakeFailedEvent;
import im.rosetta.packet.Packet0Handshake; import im.rosetta.network.enums.HandshakeStage;
import im.rosetta.packet.Packet9DeviceNew; import im.rosetta.network.packet.PacketDeviceNew;
import im.rosetta.packet.runtime.HandshakeStage; import im.rosetta.network.packet.PacketHandshake;
import im.rosetta.service.services.BufferService; import im.rosetta.service.services.BufferService;
import im.rosetta.service.services.DeviceService; import im.rosetta.service.services.DeviceService;
@@ -25,7 +25,7 @@ import io.orprotocol.lock.Lock;
import io.orprotocol.packet.PacketExecutor; import io.orprotocol.packet.PacketExecutor;
import io.orprotocol.packet.PacketManager; 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 UserRepository userRepository = new UserRepository();
private final DeviceRepository deviceRepository = new DeviceRepository(); private final DeviceRepository deviceRepository = new DeviceRepository();
@@ -35,7 +35,7 @@ public class Executor0Handshake extends PacketExecutor<Packet0Handshake> {
private final BufferRepository bufferRepository = new BufferRepository(); private final BufferRepository bufferRepository = new BufferRepository();
private final BufferService bufferService; private final BufferService bufferService;
public Executor0Handshake(EventManager eventManager, ClientManager clientManager, PacketManager packetManager) { public ExecutorHandshake(EventManager eventManager, ClientManager clientManager, PacketManager packetManager) {
this.eventManager = eventManager; this.eventManager = eventManager;
this.clientManager = clientManager; this.clientManager = clientManager;
this.bufferService = new BufferService(bufferRepository, packetManager); this.bufferService = new BufferService(bufferRepository, packetManager);
@@ -43,7 +43,7 @@ public class Executor0Handshake extends PacketExecutor<Packet0Handshake> {
@Override @Override
@Lock(lockFor = "publicKey") @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 publicKey = handshake.getPublicKey();
String privateKey = handshake.getPrivateKey(); String privateKey = handshake.getPrivateKey();
String deviceId = handshake.getDeviceId(); 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.setDeviceId(deviceId);
newDevicePacket.setDeviceName(deviceName); newDevicePacket.setDeviceName(deviceName);
newDevicePacket.setDeviceOs(deviceOs); newDevicePacket.setDeviceOs(deviceOs);

View File

@@ -0,0 +1,41 @@
package im.rosetta.executors;
import java.util.ArrayList;
import java.util.List;
import im.rosetta.network.packet.PacketIceServers;
import im.rosetta.service.services.ForwardUnitService;
import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor;
public class ExecutorIceServers extends PacketExecutor<PacketIceServers> {
private ForwardUnitService fus;
public ExecutorIceServers(ForwardUnitService fus) {
this.fus = fus;
}
@Override
public void onPacketReceived(PacketIceServers packet, Client client) throws Exception, ProtocolException {
/**
* Берем TURN сервера и отправляем их клиенту
* Такая сложная конвертация нужна потому что у нас есть тип RTCIceServer из g365sfu, который
* не совместим с типом RTCIceServer, который используется в пакете, хотя
* поля у них одинаковые нужна такая трансляция
*/
List<im.rosetta.network.types.RTCIceServer> convertedIceServers = new ArrayList<>();
for (io.g365sfu.webrtc.RTCIceServer server : this.fus.getTurnServers()) {
im.rosetta.network.types.RTCIceServer newServer = new im.rosetta.network.types.RTCIceServer();
newServer.setUrl(server.getUrl());
newServer.setUsername(server.getUsername());
newServer.setCredential(server.getCredential());
newServer.setTransport(server.getTransport());
convertedIceServers.add(newServer);
}
packet.setIceServers(convertedIceServers);
client.send(packet);
}
}

View File

@@ -5,9 +5,9 @@ import java.util.List;
import im.rosetta.Failures; import im.rosetta.Failures;
import im.rosetta.client.ClientManager; import im.rosetta.client.ClientManager;
import im.rosetta.client.tags.ECIAuthentificate; import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.packet.Packet6Message; import im.rosetta.network.packet.PacketDelivery;
import im.rosetta.packet.Packet8Delivery; import im.rosetta.network.packet.PacketMessage;
import im.rosetta.packet.runtime.Attachment; import im.rosetta.network.types.Attachment;
import im.rosetta.service.dispatch.MessageDispatcher; import im.rosetta.service.dispatch.MessageDispatcher;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
@@ -18,16 +18,16 @@ import io.orprotocol.packet.PacketManager;
/** /**
* Обработчик пакета сообщений * Обработчик пакета сообщений
*/ */
public class Executor6Message extends PacketExecutor<Packet6Message> { public class ExecutorMessage extends PacketExecutor<PacketMessage> {
private final MessageDispatcher messageDispatcher; private final MessageDispatcher messageDispatcher;
public Executor6Message(ClientManager clientManager, PacketManager packetManager) { public ExecutorMessage(ClientManager clientManager, PacketManager packetManager) {
this.messageDispatcher = new MessageDispatcher(clientManager, packetManager); this.messageDispatcher = new MessageDispatcher(clientManager, packetManager);
} }
@Override @Override
public void onPacketReceived(Packet6Message packet, Client client) throws Exception, ProtocolException { public void onPacketReceived(PacketMessage packet, Client client) throws Exception, ProtocolException {
String fromPublicKey = packet.getFromPublicKey(); String fromPublicKey = packet.getFromPublicKey();
String toPublicKey = packet.getToPublicKey(); String toPublicKey = packet.getToPublicKey();
String messageId = packet.getMessageId(); String messageId = packet.getMessageId();
@@ -117,7 +117,7 @@ public class Executor6Message extends PacketExecutor<Packet6Message> {
/** /**
* Сообщение успешно отправлено, отправялем клиенту пакет успешной доставки * Сообщение успешно отправлено, отправялем клиенту пакет успешной доставки
*/ */
Packet8Delivery deliveryPacket = new Packet8Delivery(); PacketDelivery deliveryPacket = new PacketDelivery();
deliveryPacket.setMessageId(messageId); deliveryPacket.setMessageId(messageId);
deliveryPacket.setToPublicKey(toPublicKey); deliveryPacket.setToPublicKey(toPublicKey);
client.send(deliveryPacket); client.send(deliveryPacket);

View File

@@ -7,27 +7,26 @@ import im.rosetta.Failures;
import im.rosetta.client.ClientManager; import im.rosetta.client.ClientManager;
import im.rosetta.client.OnlineManager; import im.rosetta.client.OnlineManager;
import im.rosetta.client.tags.ECIAuthentificate; import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.packet.Packet4OnlineSubscribe; import im.rosetta.network.enums.NetworkStatus;
import im.rosetta.packet.Packet5OnlineState; import im.rosetta.network.packet.PacketOnlineState;
import im.rosetta.packet.runtime.NetworkStatus; import im.rosetta.network.packet.PacketOnlineSubscribe;
import im.rosetta.packet.runtime.PKNetworkStatus; import im.rosetta.network.types.PKNetworkStatus;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client; import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor; import io.orprotocol.packet.PacketExecutor;
public class Executor4OnlineState extends PacketExecutor<Packet4OnlineSubscribe> { public class ExecutorOnlineState extends PacketExecutor<PacketOnlineSubscribe> {
private final OnlineManager onlineManager; private final OnlineManager onlineManager;
private final ClientManager clientManager; private final ClientManager clientManager;
public Executor4OnlineState(OnlineManager onlineManager, ClientManager clientManager) { public ExecutorOnlineState(OnlineManager onlineManager, ClientManager clientManager) {
this.onlineManager = onlineManager; this.onlineManager = onlineManager;
this.clientManager = clientManager; this.clientManager = clientManager;
} }
@Override @Override
public void onPacketReceived(Packet4OnlineSubscribe packet, Client client) throws Exception, ProtocolException { public void onPacketReceived(PacketOnlineSubscribe packet, Client client) throws Exception, ProtocolException {
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class); ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()) { if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()) {
/** /**
@@ -60,14 +59,17 @@ public class Executor4OnlineState extends PacketExecutor<Packet4OnlineSubscribe>
* Сразу же формируем и отправляем клиенту онлайн статус для указанных публичных ключей, чтобы клиент не ждал обновления статуса, * Сразу же формируем и отправляем клиенту онлайн статус для указанных публичных ключей, чтобы клиент не ждал обновления статуса,
* а получил его сразу после подписки * а получил его сразу после подписки
*/ */
Packet5OnlineState onlineStates = new Packet5OnlineState(); PacketOnlineState onlineStates = new PacketOnlineState();
List<PKNetworkStatus> onlineStatuses = new ArrayList<>(); List<PKNetworkStatus> onlineStatusList = new ArrayList<>();
for (String targetPublicKey : publicKeys) { for (String targetPublicKey : publicKeys) {
boolean isOnline = this.clientManager.isClientConnected(targetPublicKey); NetworkStatus networkStatus = this.clientManager.isClientConnected(targetPublicKey) ?
PKNetworkStatus networkStatus = new PKNetworkStatus(targetPublicKey, NetworkStatus.fromBoolean(isOnline)); NetworkStatus.ONLINE : NetworkStatus.OFFLINE;
onlineStatuses.add(networkStatus); PKNetworkStatus pkNetworkStatus = new PKNetworkStatus();
pkNetworkStatus.setPublicKey(targetPublicKey);
pkNetworkStatus.setNetworkStatus(networkStatus);
onlineStatusList.add(pkNetworkStatus);
} }
onlineStates.setPkNetworkStatuses(onlineStatuses); onlineStates.setPkNetworkStatuses(onlineStatusList);
client.send(onlineStates); client.send(onlineStates);
} }

View File

@@ -8,22 +8,22 @@ import im.rosetta.database.entity.Device;
import im.rosetta.database.entity.PushToken; import im.rosetta.database.entity.PushToken;
import im.rosetta.database.repository.DeviceRepository; import im.rosetta.database.repository.DeviceRepository;
import im.rosetta.database.repository.PushTokenRepository; import im.rosetta.database.repository.PushTokenRepository;
import im.rosetta.packet.Packet16PushNotification; import im.rosetta.network.enums.NotificationAction;
import im.rosetta.packet.runtime.NetworkNotificationAction; import im.rosetta.network.packet.PacketPushNotification;
import im.rosetta.service.services.DeviceService; import im.rosetta.service.services.DeviceService;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client; import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor; import io.orprotocol.packet.PacketExecutor;
public class Executor16PushNotification extends PacketExecutor<Packet16PushNotification> { public class ExecutorPushNotification extends PacketExecutor<PacketPushNotification> {
private final DeviceRepository deviceRepository = new DeviceRepository(); private final DeviceRepository deviceRepository = new DeviceRepository();
private final DeviceService deviceService = new DeviceService(deviceRepository); private final DeviceService deviceService = new DeviceService(deviceRepository);
private final PushTokenRepository pushTokenRepository = new PushTokenRepository(); private final PushTokenRepository pushTokenRepository = new PushTokenRepository();
@Override @Override
public void onPacketReceived(Packet16PushNotification packet, Client client) throws Exception, ProtocolException { public void onPacketReceived(PacketPushNotification packet, Client client) throws Exception, ProtocolException {
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class); ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()){ if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()){
/** /**
@@ -50,7 +50,7 @@ public class Executor16PushNotification extends PacketExecutor<Packet16PushNotif
} }
PushToken pushToken = this.pushTokenRepository.findToken(device, notificationToken); PushToken pushToken = this.pushTokenRepository.findToken(device, notificationToken);
if(packet.getAction() == NetworkNotificationAction.SUBSCRIBE && pushToken == null){ if(packet.getAction() == NotificationAction.SUBSCRIBE && pushToken == null){
/** /**
* Подписка на токен только если токен еще не подписан * Подписка на токен только если токен еще не подписан
*/ */
@@ -60,7 +60,7 @@ public class Executor16PushNotification extends PacketExecutor<Packet16PushNotif
token.setType(packet.getTokenType()); token.setType(packet.getTokenType());
this.pushTokenRepository.save(token); this.pushTokenRepository.save(token);
} }
if(packet.getAction() == NetworkNotificationAction.UNSUBSCRIBE && pushToken != null){ if(packet.getAction() == NotificationAction.UNSUBSCRIBE && pushToken != null){
/** /**
* Отписка от токена только если токен уже подписан * Отписка от токена только если токен уже подписан
*/ */

View File

@@ -3,7 +3,7 @@ package im.rosetta.executors;
import im.rosetta.Failures; import im.rosetta.Failures;
import im.rosetta.client.ClientManager; import im.rosetta.client.ClientManager;
import im.rosetta.client.tags.ECIAuthentificate; import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.packet.Packet7Read; import im.rosetta.network.packet.PacketRead;
import im.rosetta.service.dispatch.MessageDispatcher; import im.rosetta.service.dispatch.MessageDispatcher;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
@@ -11,16 +11,16 @@ import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor; import io.orprotocol.packet.PacketExecutor;
import io.orprotocol.packet.PacketManager; import io.orprotocol.packet.PacketManager;
public class Executor7Read extends PacketExecutor<Packet7Read> { public class ExecutorRead extends PacketExecutor<PacketRead> {
private final MessageDispatcher messageDispatcher; private final MessageDispatcher messageDispatcher;
public Executor7Read(ClientManager clientManager, PacketManager packetManager) { public ExecutorRead(ClientManager clientManager, PacketManager packetManager) {
this.messageDispatcher = new MessageDispatcher(clientManager, packetManager); this.messageDispatcher = new MessageDispatcher(clientManager, packetManager);
} }
@Override @Override
public void onPacketReceived(Packet7Read packet, Client client) throws Exception, ProtocolException { public void onPacketReceived(PacketRead packet, Client client) throws Exception, ProtocolException {
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class); ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
String fromPublicKey = packet.getFromPublicKey(); String fromPublicKey = packet.getFromPublicKey();
String toPublicKey = packet.getToPublicKey(); String toPublicKey = packet.getToPublicKey();

View File

@@ -5,17 +5,17 @@ import java.util.List;
import im.rosetta.Failures; import im.rosetta.Failures;
import im.rosetta.client.tags.ECIAuthentificate; import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.packet.Packet15RequestTransport; import im.rosetta.network.packet.PacketRequestTransport;
import im.rosetta.util.RandomUtil; import im.rosetta.util.RandomUtil;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client; import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor; import io.orprotocol.packet.PacketExecutor;
public class Executor15RequestTransport extends PacketExecutor<Packet15RequestTransport> { public class ExecutorRequestTransport extends PacketExecutor<PacketRequestTransport> {
@Override @Override
public void onPacketReceived(Packet15RequestTransport packet, Client client) throws Exception, ProtocolException { public void onPacketReceived(PacketRequestTransport packet, Client client) throws Exception, ProtocolException {
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class); ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()){ if(eciAuthentificate == null || !eciAuthentificate.hasAuthorized()){
/** /**

View File

@@ -3,7 +3,7 @@ package im.rosetta.executors;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
import im.rosetta.packet.Packet10RequestUpdate; import im.rosetta.network.packet.PacketRequestUpdate;
import im.rosetta.util.RandomUtil; import im.rosetta.util.RandomUtil;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
@@ -15,10 +15,10 @@ import io.orprotocol.packet.PacketExecutor;
* но код продублирован специально, чтобы не размазывать * но код продублирован специально, чтобы не размазывать
* его например в Dispatcher. Так читать удобнее * его например в Dispatcher. Так читать удобнее
*/ */
public class Executor10RequestUpdate extends PacketExecutor<Packet10RequestUpdate> { public class ExecutorRequestUpdate extends PacketExecutor<PacketRequestUpdate> {
@Override @Override
public void onPacketReceived(Packet10RequestUpdate packet, Client client) throws Exception, ProtocolException { public void onPacketReceived(PacketRequestUpdate packet, Client client) throws Exception, ProtocolException {
/** /**
* Обратите внимание этот пакет в отличии от Packet15RequestTransport * Обратите внимание этот пакет в отличии от Packet15RequestTransport
* не требует авторизации. Это сделано на те случаи когда приложение * не требует авторизации. Это сделано на те случаи когда приложение

View File

@@ -8,27 +8,27 @@ import im.rosetta.client.ClientManager;
import im.rosetta.client.tags.ECIAuthentificate; import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.database.entity.User; import im.rosetta.database.entity.User;
import im.rosetta.database.repository.UserRepository; import im.rosetta.database.repository.UserRepository;
import im.rosetta.packet.Packet3Search; import im.rosetta.network.enums.NetworkStatus;
import im.rosetta.packet.runtime.NetworkStatus; import im.rosetta.network.packet.PacketSearch;
import im.rosetta.packet.runtime.SearchInfo; import im.rosetta.network.types.SearchInfo;
import im.rosetta.service.services.UserService; import im.rosetta.service.services.UserService;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client; import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor; import io.orprotocol.packet.PacketExecutor;
public class Executor3Search extends PacketExecutor<Packet3Search> { public class ExecutorSearch extends PacketExecutor<PacketSearch> {
private final UserRepository userRepository = new UserRepository(); private final UserRepository userRepository = new UserRepository();
private final UserService userService = new UserService(userRepository); private final UserService userService = new UserService(userRepository);
private final ClientManager clientManager; private final ClientManager clientManager;
public Executor3Search(ClientManager clientManager) { public ExecutorSearch(ClientManager clientManager) {
this.clientManager = clientManager; this.clientManager = clientManager;
} }
@Override @Override
public void onPacketReceived(Packet3Search packet, Client client) throws Exception, ProtocolException { public void onPacketReceived(PacketSearch packet, Client client) throws Exception, ProtocolException {
String search = packet.getSearch(); String search = packet.getSearch();
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class); ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
@@ -48,24 +48,25 @@ public class Executor3Search extends PacketExecutor<Packet3Search> {
} }
List<User> usersFindedList = userService.searchUsers(search, 7); List<User> usersFindedList = userService.searchUsers(search, 7);
Packet3Search response = new Packet3Search(); PacketSearch response = new PacketSearch();
response.setSearch(""); response.setSearch("");
response.setPrivateKey(""); response.setPrivateKey("");
List<SearchInfo> searchInfos = new ArrayList<>(); List<SearchInfo> searchInfoList = new ArrayList<>();
for(User user : usersFindedList){ for(User user : usersFindedList){
SearchInfo searchInfo = new SearchInfo( NetworkStatus networkStatus = this.clientManager.isClientConnected(user.getPublicKey()) ?
user.getUsername(), NetworkStatus.ONLINE : NetworkStatus.OFFLINE;
user.getTitle(), SearchInfo searchInfo = new SearchInfo();
user.getPublicKey(), searchInfo.setNetworkStatus(networkStatus);
user.getVerified(), searchInfo.setTitle(user.getTitle());
NetworkStatus.fromBoolean(this.clientManager.isClientConnected(user.getPublicKey())) searchInfo.setUsername(user.getUsername());
); searchInfo.setVerified(user.getVerified());
searchInfos.add(searchInfo); searchInfo.setPublicKey(user.getPublicKey());
searchInfoList.add(searchInfo);
} }
response.setSearchInfos(searchInfos); response.setSearchInfo(searchInfoList);
client.send(response); client.send(response);
} }

View File

@@ -0,0 +1,223 @@
package im.rosetta.executors;
import java.util.HashMap;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import im.rosetta.Failures;
import im.rosetta.calls.CallManager;
import im.rosetta.calls.CallSession;
import im.rosetta.client.ClientManager;
import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.network.enums.SignalType;
import im.rosetta.network.packet.PacketSignalPeer;
import im.rosetta.service.dispatch.push.PushNotifyDispatcher;
import im.rosetta.service.dispatch.runtime.PushType;
import im.rosetta.service.services.ForwardUnitService;
import io.g365sfu.Room;
import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor;
/**
* Используется в Peer To Peer звонках, в групповых звонках другой сигналинг
*/
public class ExecutorSignalPeer extends PacketExecutor<PacketSignalPeer> {
private ClientManager clientManager;
private ForwardUnitService fus;
private PushNotifyDispatcher pushNotifyDispatcher = new PushNotifyDispatcher();
/**
* Сигналы, которые может выполнять только авторизованный пользователь,
* все сигналы, которые не входят в этот перечень, будут доступны для
* исполнения без авторизации.
*/
private Set<SignalType> authentificatedTypes = new HashSet<>(){{
add(SignalType.CALL);
}};
/**
* Менеджер звонков, который реализует весь необхоимый функционал для управления звонками,
* например проверку занятости пользователя, и тд
*/
private CallManager callManager;
public ExecutorSignalPeer(ClientManager clientManager, ForwardUnitService fus, CallManager callManager) {
this.clientManager = clientManager;
this.fus = fus;
this.callManager = callManager;
}
@Override
public void onPacketReceived(PacketSignalPeer packet, Client client) throws Exception, ProtocolException {
String src = packet.getSrc();
String dst = packet.getDst();
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
SignalType type = packet.getSignalType();
if ((eciAuthentificate == null || !eciAuthentificate.hasAuthorized())
&& this.authentificatedTypes.contains(type)) {
/**
* Если клиент не авторизован, то мы не будем обрабатывать его сигналы на инициализацию звонка и создание комнаты
* и просто отключим его от сервера.
*/
client.disconnect(Failures.HANDSHAKE_NOT_COMPLETED);
return;
}
if(src != null && !src.equals(eciAuthentificate.getPublicKey()) && authentificatedTypes.contains(type)) {
/**
* Если src в пакете не совпадает с авторизованным PK клиента, то это может означать, что клиент пытается
* отправить сигнал от другого пользователя, отключаем его от сервера.
*/
client.disconnect(Failures.DATA_MISSMATCH);
return;
}
if(type == SignalType.CALL) {
/**
* Инициируется звонок от src к dst, проверяем, что dst не занят другим звонком, если занят, то отправляем сигнал END_CALL_BECAUSE_BUSY обратно src
*/
if(this.callManager.isBusy(dst) || this.callManager.isBusy(src)) {
/**
* Получатель сигнала уже находится в другой комнате, значит он занят другим звонком, отправляем сигнал END_CALL_BECAUSE_BUSY обратно src
*/
PacketSignalPeer responsePacket = new PacketSignalPeer();
responsePacket.setSignalType(SignalType.END_CALL_BECAUSE_BUSY);
client.send(responsePacket);
return;
}
/**
* Генерируем CallID и JoinToken
*/
String callId = UUID.randomUUID().toString();
String joinToken = UUID.randomUUID().toString();
packet.setJoinToken(joinToken);
packet.setCallId(callId);
/**
* Создаем сессию звонка и добавляем в нее звонящего
*/
CallSession session = this.callManager.createCall(callId, joinToken);
session.joinCall(src, client);
/**
* Добавляем dst в ringing, чтобы пометить, что ему поступает звонок
*/
session.addRinging(dst);
/**
* Получатель сигнала не занят, отправляем ему пуш уведомление о входящем звонке и сигнал CALL для инициализации звонка
*/
pushNotifyDispatcher.sendPush(dst, new HashMap<>(){{
put("type", PushType.CALL);
put("dialog", src);
put("callId", callId);
put("joinToken", joinToken);
}});
/**
* Отправляем сигнал CALL всем авторизованным устройствам вызываемого абонента
*/
this.clientManager.sendPacketToAuthorizedPK(dst, packet);
return;
}
if(type == SignalType.ACCEPT){
String callId = packet.getCallId();
String joinToken = packet.getJoinToken();
CallSession session = this.callManager.getCallSession(callId, joinToken);
if(session == null) {
/**
* Сессии звонка нет
*/
client.disconnect(Failures.NO_CALL_SESSION);
return;
}
if(!session.isValidSource(src)) {
/**
* Клиент не состоит в сессии звонка, отключаем его от сервера, так как он отправляет некорректные данные
*/
client.disconnect(Failures.DATA_MISSMATCH);
return;
}
Room room = this.fus.createRoom();
session.setRoom(room);
session.joinCall(src, client);
for(String participant : session.clients.keySet()) {
room.addParticipant(participant);
}
session.sendPacket(packet, client);
/**
* Сбрасываем вызов на всех остальных устройствах пользователя, который принимает звонок,
* чтобы он не смог принять или отклонить звонок с другого устройства
*/
PacketSignalPeer endCallOtherDevices = new PacketSignalPeer();
endCallOtherDevices.setSignalType(SignalType.END_CALL);
this.clientManager.sendPacketToAuthorizedPK(src, endCallOtherDevices, client);
return;
}
if(type == SignalType.KEY_EXCHANGE){
/**
* Ретранслируем ключи в рамках сессии
*/
CallSession session = this.callManager.getCallSession(client);
if(session == null) {
/**
* Сессии звонка нет
*/
client.disconnect(Failures.NO_CALL_SESSION);
return;
}
/**
* Обмениваемся ключами в рамках сессии, ретранслируя их всем участникам сессии, кроме отправителя
*/
session.sendPacket(packet, client);
return;
}
if(type == SignalType.END_CALL) {
/**
* Ретранслируем сигнал окончания звонка всем участникам сессии, кроме отправителя, и удаляем сессию
*/
/**
* Сначала получаем сессию по сокету отправителя пакета, если не находим, то пробуем найти сессию по callId и joinToken из пакета, если не находим,
* то отключаем клиента от сервера, так как он отправляет некорректные данные
*/
CallSession session = this.callManager.getCallSession(client);
if(session == null) {
String callId = packet.getCallId();
String joinToken = packet.getJoinToken();
session = this.callManager.getCallSession(callId, joinToken);
}
if(session == null) {
/**
* Сессии звонка нет, скорее всего она была удалена при обрыве RTC Peer Connection,
* при срабатывании RTCPeerConnection::close на клиенте раньше, чем клиент отправил сигнал END_CALL
*/
return;
}
/**
* Отправляем сигнал окончания звонка всем участникам сессии, кроме отправителя
*/
session.sendPacket(packet, client);
/**
* Отправляем пакет вызываемым (ringing) пользователям (которые еще не в сессии)
*/
this.callManager.sendPacketToRinging(session, packet);
/**
* Удаляем сессию из активных сессий звонков
*/
this.callManager.removeSession(session);
return;
}
if(type == SignalType.ACTIVE) {
/**
* Клиент сообщил, что прошел стадию обмена ключами и звонок активен
*/
CallSession session = this.callManager.getCallSession(client);
if(session == null) {
/**
* Сессии звонка нет
*/
client.disconnect(Failures.NO_CALL_SESSION);
return;
}
session.sendPacket(packet, null);
}
}
}

View File

@@ -3,8 +3,8 @@ package im.rosetta.executors;
import java.util.List; import java.util.List;
import im.rosetta.database.repository.BufferRepository; import im.rosetta.database.repository.BufferRepository;
import im.rosetta.packet.Packet25Sync; import im.rosetta.network.enums.SyncStatus;
import im.rosetta.packet.runtime.NetworkSyncStatus; import im.rosetta.network.packet.PacketSync;
import im.rosetta.service.services.BufferService; import im.rosetta.service.services.BufferService;
import im.rosetta.service.services.runtime.PacketBuffer; import im.rosetta.service.services.runtime.PacketBuffer;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
@@ -13,17 +13,17 @@ import io.orprotocol.packet.Packet;
import io.orprotocol.packet.PacketExecutor; import io.orprotocol.packet.PacketExecutor;
import io.orprotocol.packet.PacketManager; import io.orprotocol.packet.PacketManager;
public class Executor25Sync extends PacketExecutor<Packet25Sync> { public class ExecutorSync extends PacketExecutor<PacketSync> {
private final BufferRepository bufferRepository = new BufferRepository(); private final BufferRepository bufferRepository = new BufferRepository();
private final BufferService bufferService; private final BufferService bufferService;
public Executor25Sync(PacketManager packetManager) { public ExecutorSync(PacketManager packetManager) {
this.bufferService = new BufferService(bufferRepository, packetManager); this.bufferService = new BufferService(bufferRepository, packetManager);
} }
@Override @Override
public void onPacketReceived(Packet25Sync packet, Client client) throws Exception, ProtocolException { public void onPacketReceived(PacketSync packet, Client client) throws Exception, ProtocolException {
/** /**
* Начиная с какого времени клиент желает получить синхронизацию * Начиная с какого времени клиент желает получить синхронизацию
*/ */
@@ -36,7 +36,7 @@ public class Executor25Sync extends PacketExecutor<Packet25Sync> {
/** /**
* Нет пакетов для синхронизации, сообщаем клиенту что он синхронизирован * Нет пакетов для синхронизации, сообщаем клиенту что он синхронизирован
*/ */
packet.setSyncStatus(NetworkSyncStatus.NOT_NEEDED); packet.setSyncStatus(SyncStatus.NOT_NEEDED);
client.send(packet); client.send(packet);
return; return;
} }
@@ -44,7 +44,7 @@ public class Executor25Sync extends PacketExecutor<Packet25Sync> {
/** /**
* Отправляем клиенту информацию о том, что синхронизация началась * Отправляем клиенту информацию о том, что синхронизация началась
*/ */
packet.setSyncStatus(NetworkSyncStatus.BATCH_START); packet.setSyncStatus(SyncStatus.BATCH_START);
client.send(packet); client.send(packet);
/** /**
@@ -58,7 +58,7 @@ public class Executor25Sync extends PacketExecutor<Packet25Sync> {
/** /**
* Сообщаем клиенту, что синхронизация завершена * Сообщаем клиенту, что синхронизация завершена
*/ */
packet.setSyncStatus(NetworkSyncStatus.BATCH_END); packet.setSyncStatus(SyncStatus.BATCH_END);
packet.setTimestamp(packetBuffer.getLastPacketTimestamp()); packet.setTimestamp(packetBuffer.getLastPacketTimestamp());
client.send(packet); client.send(packet);
} }

View File

@@ -3,7 +3,7 @@ package im.rosetta.executors;
import im.rosetta.Failures; import im.rosetta.Failures;
import im.rosetta.client.ClientManager; import im.rosetta.client.ClientManager;
import im.rosetta.client.tags.ECIAuthentificate; import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.packet.Packet11Typeing; import im.rosetta.network.packet.PacketTypeing;
import im.rosetta.service.dispatch.MessageDispatcher; import im.rosetta.service.dispatch.MessageDispatcher;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
@@ -11,16 +11,16 @@ import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor; import io.orprotocol.packet.PacketExecutor;
import io.orprotocol.packet.PacketManager; import io.orprotocol.packet.PacketManager;
public class Executor11Typeing extends PacketExecutor<Packet11Typeing> { public class ExecutorTypeing extends PacketExecutor<PacketTypeing> {
private final MessageDispatcher messageDispatcher; private final MessageDispatcher messageDispatcher;
public Executor11Typeing(ClientManager clientManager, PacketManager packetManager) { public ExecutorTypeing(ClientManager clientManager, PacketManager packetManager) {
this.messageDispatcher = new MessageDispatcher(clientManager, packetManager); this.messageDispatcher = new MessageDispatcher(clientManager, packetManager);
} }
@Override @Override
public void onPacketReceived(Packet11Typeing packet, Client client) throws Exception, ProtocolException { public void onPacketReceived(PacketTypeing packet, Client client) throws Exception, ProtocolException {
ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class); ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
String fromPublicKey = packet.getFromPublicKey(); String fromPublicKey = packet.getFromPublicKey();
String toPublicKey = packet.getToPublicKey(); String toPublicKey = packet.getToPublicKey();

View File

@@ -9,16 +9,16 @@ import im.rosetta.Failures;
import im.rosetta.client.tags.ECIAuthentificate; import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.database.entity.User; import im.rosetta.database.entity.User;
import im.rosetta.database.repository.UserRepository; import im.rosetta.database.repository.UserRepository;
import im.rosetta.packet.Packet1UserInfo; import im.rosetta.network.enums.ResultCode;
import im.rosetta.packet.Packet2Result; import im.rosetta.network.packet.PacketResult;
import im.rosetta.packet.runtime.ResultCode; import im.rosetta.network.packet.PacketUserInfo;
import im.rosetta.service.services.UserService; import im.rosetta.service.services.UserService;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client; import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor; 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 UserRepository userRepository = new UserRepository();
private final UserService userService = new UserService(userRepository); private final UserService userService = new UserService(userRepository);
@@ -32,11 +32,12 @@ public class Executor1UserInfo extends PacketExecutor<Packet1UserInfo> {
"deleted", "deleted",
"safety", "safety",
"secure", "secure",
"rosettasafe" "rosettasafe",
"rosettadev1"
)); ));
@Override @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); ECIAuthentificate eciAuthentificate = client.getTag(ECIAuthentificate.class);
String username = packet.getUsername(); String username = packet.getUsername();
String title = packet.getTitle(); 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); result.setResultCode(ResultCode.USERNAME_TAKEN);
client.send(result); client.send(result);
return; return;
@@ -73,7 +74,7 @@ public class Executor1UserInfo extends PacketExecutor<Packet1UserInfo> {
/** /**
* Не удалось сменить username, отправляем клиенту ошибку * Не удалось сменить username, отправляем клиенту ошибку
*/ */
Packet2Result result = new Packet2Result(); PacketResult result = new PacketResult();
result.setResultCode(ResultCode.INVALID); result.setResultCode(ResultCode.INVALID);
client.send(result); client.send(result);
return; return;
@@ -84,7 +85,7 @@ public class Executor1UserInfo extends PacketExecutor<Packet1UserInfo> {
/** /**
* Не удалось сменить title, отправляем клиенту ошибку * Не удалось сменить title, отправляем клиенту ошибку
*/ */
Packet2Result result = new Packet2Result(); PacketResult result = new PacketResult();
result.setResultCode(ResultCode.INVALID); result.setResultCode(ResultCode.INVALID);
client.send(result); client.send(result);
return; return;
@@ -93,7 +94,7 @@ public class Executor1UserInfo extends PacketExecutor<Packet1UserInfo> {
/** /**
* Отправляем клиенту успешный результат * Отправляем клиенту успешный результат
*/ */
Packet2Result result = new Packet2Result(); PacketResult result = new PacketResult();
result.setResultCode(ResultCode.SUCCESS); result.setResultCode(ResultCode.SUCCESS);
client.send(result); client.send(result);
} }

View File

@@ -0,0 +1,80 @@
package im.rosetta.executors;
import im.rosetta.Failures;
import im.rosetta.calls.CallManager;
import im.rosetta.calls.CallSession;
import im.rosetta.network.enums.WebRTCType;
import im.rosetta.network.packet.PacketWebRTC;
import io.g365sfu.Room;
import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client;
import io.orprotocol.packet.PacketExecutor;
public class ExecutorWebRTC extends PacketExecutor<PacketWebRTC> {
private CallManager callManager;
public ExecutorWebRTC(CallManager callManager) {
this.callManager = callManager;
}
@Override
public void onPacketReceived(PacketWebRTC packet, Client client) throws Exception, ProtocolException {
/**
* Получаем, в какой сессии находится этот сокет
*/
CallSession session = this.callManager.getCallSession(client);
if(session == null) {
/**
* Если сессия не найдена, то мы не будем обрабатывать сигналы для звонка
*/
return;
}
Room room = session.getRoom();
if(room == null) {
/**
* Звонок еще не активен, а значит комнаты еще нет. Нельзя обменяться WebRTC сигналами пока комнаты еще нет.
*/
return;
}
/**
* Получаем публичный ключ, которым представился клиент, в рамках сессии звонка.
* Мы не делаем это через ECIAuthentificate, так как в рамках звонка клиент может не быть авторизован, но при этом он уже находится в сессии звонка, и мы можем идентифицировать его по публичному ключу,
* который он указал при присоединении к звонку используя joinToken.
* Так что, несмотря на то, что клиент может быть не авторизован, мы все равно можем достоверно знать его публичный ключ
*/
String publicKey = session.getPublicKey(client);
if(publicKey == null) {
/**
* Избыточная проверка, так как если клиент находится в сессии, то он должен быть в списке клиентов сессии,
* но на всякий случай проверим это, чтобы избежать возможных ошибок
*/
client.disconnect(Failures.DATA_MISSMATCH);
return;
}
WebRTCType type = packet.getType();
if(type == WebRTCType.OFFER) {
/**
* Если это OFFER, то отправляем OFFER на сервер SFU,
* который отвечает за эту комнату, чтобы он транслировал его всем участникам комнаты, кроме отправителя
*/
room.sdpOffer(publicKey, packet.getSdpOrCandidate());
}
if(type == WebRTCType.ICE_CANDIDATE) {
/**
* Если это ICE кандидат, то отправляем его на сервер SFU,
* который отвечает за эту комнату, чтобы он транслировал его всем участникам комнаты, кроме отправителя
*/
room.iceCandidate(publicKey, packet.getSdpOrCandidate());
}
if(type == WebRTCType.ANSWER) {
/**
* Если это ANSWER, то отправляем его на сервер SFU,
* который отвечает за эту комнату, чтобы он транслировал его всем участникам комнаты, кроме отправителя
*/
room.sdpAnswer(publicKey, packet.getSdpOrCandidate());
}
}
}

View File

@@ -9,10 +9,9 @@ import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.event.EventHandler; import im.rosetta.event.EventHandler;
import im.rosetta.event.Listener; import im.rosetta.event.Listener;
import im.rosetta.event.events.DisconnectEvent; import im.rosetta.event.events.DisconnectEvent;
import im.rosetta.packet.Packet5OnlineState; import im.rosetta.network.enums.NetworkStatus;
import im.rosetta.packet.runtime.NetworkStatus; import im.rosetta.network.packet.PacketOnlineState;
import im.rosetta.packet.runtime.PKNetworkStatus; import im.rosetta.network.types.PKNetworkStatus;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client; import io.orprotocol.client.Client;
@@ -59,13 +58,13 @@ public class OnlineStatusDisconnectListener implements Listener {
* Уведомляем всех подписчиков на его онлайн статус, что он отключился (ушел в оффлайн) * Уведомляем всех подписчиков на его онлайн статус, что он отключился (ушел в оффлайн)
*/ */
for (Client subscriber : subscribers) { for (Client subscriber : subscribers) {
Packet5OnlineState packet = new Packet5OnlineState(); PacketOnlineState packet = new PacketOnlineState();
List<PKNetworkStatus> statuses = new ArrayList<>(); List<PKNetworkStatus> statusList = new ArrayList<>();
statuses.add(new PKNetworkStatus( PKNetworkStatus status = new PKNetworkStatus();
eciAuthentificate.getPublicKey(), status.setPublicKey(eciAuthentificate.getPublicKey());
NetworkStatus.OFFLINE status.setNetworkStatus(NetworkStatus.OFFLINE);
)); statusList.add(status);
packet.setPkNetworkStatuses(statuses); packet.setPkNetworkStatuses(statusList);
subscriber.send(packet); subscriber.send(packet);
} }
/** /**

View File

@@ -8,10 +8,9 @@ import im.rosetta.client.tags.ECIAuthentificate;
import im.rosetta.event.EventHandler; import im.rosetta.event.EventHandler;
import im.rosetta.event.Listener; import im.rosetta.event.Listener;
import im.rosetta.event.events.handshake.HandshakeCompletedEvent; import im.rosetta.event.events.handshake.HandshakeCompletedEvent;
import im.rosetta.packet.Packet5OnlineState; import im.rosetta.network.enums.NetworkStatus;
import im.rosetta.packet.runtime.NetworkStatus; import im.rosetta.network.packet.PacketOnlineState;
import im.rosetta.packet.runtime.PKNetworkStatus; import im.rosetta.network.types.PKNetworkStatus;
import io.orprotocol.ProtocolException; import io.orprotocol.ProtocolException;
import io.orprotocol.client.Client; import io.orprotocol.client.Client;
@@ -45,14 +44,14 @@ public class OnlineStatusHandshakeCompleteListener implements Listener {
* Уведомляем всех подписчиков на его онлайн статус, что он подключился (стал онлайн) * Уведомляем всех подписчиков на его онлайн статус, что он подключился (стал онлайн)
*/ */
for (Client subscriber : subscribers) { for (Client subscriber : subscribers) {
Packet5OnlineState packet = new Packet5OnlineState(); PacketOnlineState packet = new PacketOnlineState();
List<PKNetworkStatus> statuses = new ArrayList<>(); List<PKNetworkStatus> statusList = new ArrayList<>();
statuses.add(new PKNetworkStatus( PKNetworkStatus status = new PKNetworkStatus();
eciAuthentificate.getPublicKey(), status.setPublicKey(eciAuthentificate.getPublicKey());
NetworkStatus.ONLINE status.setNetworkStatus(NetworkStatus.ONLINE);
)); statusList.add(status);
packet.setPkNetworkStatuses(statuses); packet.setPkNetworkStatuses(statusList);
subscriber.send(packet); subscriber.send(packet);
} }
} }

View 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());
}
}

View 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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View 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.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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View 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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View File

@@ -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();
}
}

View 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.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();
}
}

View File

@@ -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();
}
}

View 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();
}
}

View 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.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();
}
}

View 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.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();
}
}

View 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.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();
}
}

View File

@@ -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;
}
}

View 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;
}
}

View 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);
}
}
}

View 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);
}
}
}

View 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);
}
}
}

View 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);
}
}
}

View 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);
}
}
}

View File

@@ -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);
}
}
}

View 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);
}
}
}

View 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);
}
}
}

View 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);
}
}
}

View 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);
}
}
}

View 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);
}
}
}

View 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;
}
}

View 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.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;
}
}

View 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;
}
}

View 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.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;
}
}

View 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;
}
}

View File

@@ -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;
}
}

View 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;
}
}

View 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 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;
}
}

View 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;
}
}

View File

@@ -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;
}
}

View 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;
}
}

View 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.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;
}
}

View 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;
}
}

View 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.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;
}
}

View 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 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;
}
}

View File

@@ -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;
}
}

View 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;
}
}

View File

@@ -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;
}
}

View File

@@ -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;
}
}

View 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;
}
}

View 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;
}
}

View File

@@ -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;
}
}

View 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;
}
}

Some files were not shown because too many files have changed in this diff Show More