Code Monkey home page Code Monkey logo

Comments (2)

readyblue avatar readyblue commented on August 13, 2024 2

With all due respect, there may be a reason why it might be a good idea to keep message delivery in order, like:
meme_msg_not_delivered_in_order

from atox.

robinlinden avatar robinlinden commented on August 13, 2024

Hi @readyblue!

While TOX implements read receipts, would be possible to implement mechanism that sends message only after the read receipts gets delivered from previous message?

aTox should already be resending all undelivered messages in the correct order, but we don't wait for one message to be acknowledged before sending the next, so I guess in theory a message could get lost a second time, and then we'd end up with out-of-order problems. If you feel like having a look at making a PR for this, it'd be very welcome. :) After speaking to a friend, this shouldn't be able to happen either. Have you had messages delivered out-of-order from aTox to aTox, uTox, Toxic, or qTox?

See:

fun resend(messages: List<Message>) = scope.launch {
for (message in messages) {
val msgs = message.message.chunked(MAX_MESSAGE_LENGTH)
while (msgs.size > 1) {
tox.sendMessage(PublicKey(message.publicKey), msgs.removeFirst(), message.type)
}
messageRepository.setCorrelationId(
message.id,
tox.sendMessage(PublicKey(message.publicKey), msgs.first(), message.type),
)
}
}

friendConnectionStatusHandler = { publicKey, status ->
contactRepository.setConnectionStatus(publicKey, status)
if (status != ConnectionStatus.None) {
scope.launch {
val pending = messageRepository.getPending(publicKey)
if (pending.isNotEmpty()) {
chatManager.resend(pending)
}

And also display this event in the chat log window so that it will be possible to resend the message without read receipts delivered?

aTox already resends all messages that it doesn't get read-receipts for, so if aTox doesn't display "sending" under a message, the Tox client on the other side has sent a read-receipt. Are you sure it's not the other side dropping the messages after receiving them and sending a read-receipt?

See:

fun sendMessage(publicKey: PublicKey, message: String, type: MessageType = MessageType.Normal) =
scope.launch {
if (contactRepository.get(publicKey.string()).first().connectionStatus == ConnectionStatus.None) {
queueMessage(publicKey, message, type)
return@launch
}
val msgs = message.chunked(MAX_MESSAGE_LENGTH)
while (msgs.size > 1) {
tox.sendMessage(publicKey, msgs.removeFirst(), type)
}
messageRepository.add(
Message(
publicKey.string(),
message,
Sender.Sent,
type,
tox.sendMessage(publicKey, msgs.first(), type),
),
)
}

friendReadReceiptHandler = { publicKey, messageId ->
messageRepository.setReceipt(publicKey, messageId, Date().time)
}

val unsent = message.timestamp == 0L
vh.message.text = message.message
vh.timestamp.text = if (!unsent) {
timeFormatter.format(message.timestamp)
} else {
resources.getText(R.string.sending)
}

Thank you for getting in touch! Always nice to hear from people using aTox!

from atox.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.