Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -163,6 +163,22 @@ public void sendFile(String filePath, String address, String chatId) {
}
}

public void sendFile(byte[] fileBytes, String fileName, String address, String chatId) {
String fileId = UUID.randomUUID().toString();
MessageFileStartEvent messageFileStartEvent = new MessageFileStartEvent(address, System.currentTimeMillis(), fileId, chatId, fileName, fileBytes.length);

try {
KaonicEvent<MessageFileStartEvent> kaonicEvent = new KaonicEvent<>(KaonicEventType.MESSAGE_FILE_START,
messageFileStartEvent);
transmitFile(kaonicEvent);

onEventReceived(objectMapper.writeValueAsString(new KaonicEvent<>(KaonicEventType.MESSAGE_FILE,
new MessageFileEvent(address, System.currentTimeMillis(), fileId, chatId, fileName, fileBytes.length))));
} catch (JsonProcessingException e) {
Log.e(TAG, "Failed to send " + fileName, e);
}
}

public void sendBroadcast(String id, String topic, byte[] data) {
kaonicLib.sendBroadcast(id, topic, data);
}
Expand Down