Open mkapal opened 1 month ago
From experience, it's very useful to have abstractions like these for some specific packets, especially buttons as the Text field has some complex behaviour.
Something you may also want to have in the back of your head, at some point in insim.rs I had a send_and_wait_for_response
style method where it would automatically set the reqi
on a given packet (ensuring it was unique on a per-insim-connection basis), and then wait for a response where the reqi
was the same, and then return the packet.
I dropped it, with the plan to bring it back (eventually) - but it is something I've needed at some point in most insim things I've worked on.
@theangryangel Thanks, that's a good idea, I will consider it for the future.
I wonder if it would make sense to add new methods to the
InSim
class, which would make it easier to send or receive packets without having to remember the exact packets and packet properties to send.There is already a small abstraction like this - the InSim connection method. Instead of sending an
IS_ISI
packet, but you just callinSim.connect()
. A similar approach could be taken with other packets.Example 1 - sending a button
Problem:
Text
property delimited by zero-bytes:'\0Caption\0Text'
.Current API
Proposed API
Example 2 - sending a message or a command
Problem:
IS_MST
packet, otherwise you can decide betweenIS_MST
andIS_MSX
depending on the message length.IS_MTC
.Current API
Proposed API
There could be one method called
sendMessage()
or maybe justsend()
which would accept a text string: