fix #204 - throw error if sent message is too long

This commit is contained in:
Kevin Hester 2020-11-21 08:41:26 +08:00
parent 6e2cb723ea
commit 5007019a2e
2 changed files with 6 additions and 1 deletions

View file

@ -1458,6 +1458,11 @@ class MeshService : Service(), Logging {
// Keep a record of datapackets, so GUIs can show proper chat history
rememberDataPacket(p)
if(p.bytes.size >= MeshProtos.Constants.DATA_PAYLOAD_LEN.number) {
p.status = MessageStatus.ERROR
throw RemoteException("Message too long")
}
if (p.id != 0) { // If we have an ID we can wait for an ack or nak
deleteOldPackets()
sentPackets[p.id] = p