Pass a Message object to listen event
WolfGang Senizen
Provide listen event with an object representing the message instead of the LSL parameters
channel
, name
, id
, message
I'd propose if possible an object with the following structure
type ChatMessage = {
_id: number,
from : uuid,
owner: uuid, -- same as ll.GetOwnerKey on from, but preloaded to prevent loss on disappearing objects (and maybe cross region?)
name: string,
channel: number,
listener: number, -- the same as the return for the llListen that setup this hook
length: number, -- length in bytes for the message
getText: (self: ChatMessage) -> string, -- retrieves the message corresponding to _id
}
Example use
LLEvents:on("listen",function(msg)
ll.OwnerSay(`from {msg.name}`)
ll.OwnerSay(`with id {msg.from}`)
ll.OwnerSay(`on channel {msg.channel}`)
ll.OwnerSay(`it is {msg.length} bytes long`)
if msg.length < 500 then
ll.OwnerSay(`message: {msg:getText()}`)
end
ll.ListenRemove(msg.listener)
end)
This would make clearing listeners in the event itself allot cleaner.
And also address the OOM issue of receiving too much text, (though yes that is slightly alleviated with 128k memory and chat having less than 1k max).
If listen handle or owner, is not easily/reliably available right now, they should be addable at a later date without affecting existing scripts
Log In
Nexii Malthus
Bonus points if the
owner
could also pass across regions for objects communicating across the border, as llGetOwnerKey
doesn't work. This would really help multi-region systems to communicate safely without the overhead and complexity of security handshakes.