Commit graph

1821 commits

Author SHA1 Message Date
Eric House
d0a53ab3ff send invites as invites, not messages
Fixes sending of invitations on Android
2023-03-27 14:33:14 -07:00
Eric House
50ac11970e fix assertion failure when sending single unqueued message 2023-03-26 10:37:45 -07:00
Eric House
885a20845a don't send null msg queue 2023-03-25 15:31:15 -07:00
Eric House
1a8f91203e Send MQTT messages in batches
Resend sends all types in batches. Send of new messages goes back for
MQTT only and sends the whole un-ack'd queue.
2023-03-25 10:24:39 -07:00
Eric House
326624e942 on linux, keep a queue of mqtt messages
Was dropping invitations that were posted before I connected to the
remote broker. Now they're kept, and sent until the broker says
publish succeeded. Better would be to have comms resend when mqtt
connects, but I'm not set up for that.
2023-03-25 10:24:39 -07:00
Eric House
7b2c327ba8 change send method to take list instead of array 2023-03-25 10:24:39 -07:00
Eric House
22d0d50130 add a public part of MsgQueueElem to simplify passing outside 2023-03-25 10:24:39 -07:00
Eric House
6ec0e64657 toward changing APIs to allow combined messages for mqtt 2023-03-25 10:24:39 -07:00
Eric House
b811653c89 remove ifdef-d out code storing all messages in one queue 2023-03-25 10:24:39 -07:00
Eric House
7929ddea47 cleanup comms 2023-03-25 10:24:39 -07:00
Eric House
daac5ca098 store messages in channel rather than a single queue
Moving toward being able to send in groups per device for MQTT
optimization
2023-03-16 07:44:14 -07:00
Eric House
b27384df63 print caller in logging func 2023-03-16 07:44:14 -07:00
Eric House
fb04a6ad0a fix server_getOpenChannel()
Only used by gtk for now but meant to replace hardcoded invitation
code everywhere.
2023-03-16 07:44:14 -07:00
Eric House
e849d628d9 log when messages could be combined 2023-03-16 07:43:51 -07:00
Eric House
bb2a2dacae cleanup 2023-03-08 20:48:55 -08:00
Eric House
073271fe61 tweak test script to better test rematching 2023-03-08 20:48:55 -08:00
Eric House
1083cbd525 improve test script and fix rematching bug it found
Server needs to not rematch if any device has more than one
player (for now, as I'm too lazy to fix this rare condition.) I'm
moving toward having the linux client write status to a unix socket on
exit rather than having the test script parse the log file for
status. GameOver is there now. Tile counts should follow.
2023-03-05 10:23:48 -08:00
Eric House
ac75da2028 fix leak rematching games on 3+ devices 2023-03-04 09:30:58 -08:00
Eric House
4ec6cfe17d plug memory leak 2023-03-04 08:54:31 -08:00
Eric House
07cd95e715 use github code to implement md5sum for mqtt msg ack (wasm only) 2023-02-26 19:53:12 -08:00
Eric House
22bf6c596a as copied from https://github.com/Zunawe/md5-c 2023-02-26 19:53:12 -08:00
Eric House
b758cd3f0f respond to invitations coming in as argv params
including downloading wordlist if necessary
2023-02-26 19:53:12 -08:00
Eric House
32275017a6 implement rematch 2023-02-23 15:51:40 -08:00
Eric House
a0f5e2d5d4 remove dead code 2023-02-23 10:55:05 -08:00
Eric House
5382941f63 snapshot: play via MQTT works for a while 2023-02-22 19:52:45 -08:00
Eric House
78d84a941e compiles, but untested
And certainly won't work!
2023-02-22 19:04:05 -08:00
Eric House
fd36590e7f fix assertions that assumed multi-device 2023-02-21 17:32:21 -08:00
Eric House
9ca291cf0d enable rematch for 3- and 4-device games
Because only the host/inviter knows the addresses of all the devices
in a game it's hard for guests to rematch (unless it's a 2-device
game, as they know the host's address.) So now, as part of telling
guests the game is ready to play, include the addresses of other
guests. It's usually only 9 bytes per device, and only happens when
more than two devices are in a game.
2023-02-16 21:36:46 -08:00
Eric House
ee859a6c6a cleanup: remove dead code 2023-02-15 08:31:51 -08:00
Eric House
34ba254e64 cleanup 2023-02-11 07:50:53 -08:00
Eric House
0e14783d3b use negotiated streamVersion to decide what to send via MQTT
No point in sending the old-topic-format MQTT messages to clients that
know about the new one, and in fact it's harmful. Devices in a game
already agree on the stream version to use and communicate it, so pass
that into comms once it's known and from there on to the device code
that builds mqtt messages.
2023-02-09 16:53:18 -08:00
Eric House
d924776a84 make invitation to three-device games work on gtk/linux 2023-02-08 10:28:00 -08:00
Eric House
646e806ae4 get rid of stream_open(), which was a NO-OP 2023-02-04 07:44:57 -08:00
Eric House
4a57b76817 cleanup: pass xwe with closeProc rather than to destroy
It's only needed when there's a close proc, and that's rare.
2023-02-03 22:00:47 -08:00
Eric House
e79450ab4c refactor message queue access
Cleanup to reduce changes when queue storage changes, which is coming
to optimize mqtt sends.
2023-02-03 10:18:54 -08:00
Eric House
c820abb514 remove unused params 2023-02-03 10:18:54 -08:00
Eric House
fcff8dab35 send from inside comms_invite on Linux but not Android
This is probably a temporary fix for Linux not being aggressive enough
about calling comms_resendAll() when opening a game. For now, though,
test scripts fail without it.
2023-01-30 12:02:46 -08:00
Eric House
18973675d0 don't send invite from inside comms_invite() 2023-01-27 21:07:39 -08:00
Eric House
a6d1736a7e replace assertion with logging 2023-01-26 11:20:40 -08:00
Eric House
863a54bfe1 Once received, nuke invite on mqtt broker
To prevent deleted games' ghost invitations from remaining as
persisted on a topic and so being received over and over, have
recipient of invitation send an empty message on the same topic to
remove them. Any message sent once the game start would have replaced
the invitation, but sometimes if the sender is deleted at the right
time there's none.
2023-01-24 17:23:30 -08:00
Eric House
6bb14548c9 fix TransportSendInvt to include type
In failing to pass the type into TransportSendInvt I was forcing
implementations to send to all types, which led to a lot of duplicate
invitations.
2023-01-24 17:11:05 -08:00
Eric House
ffe571664c remove asserts flagging problems I can't fix yet 2023-01-24 11:38:11 -08:00
Eric House
7fdf43eba6 add logging 2023-01-23 22:08:50 -08:00
Eric House
873501f8da changes for better testing invites and sms 2023-01-17 18:01:30 -08:00
Eric House
f1262e49e7 remove unused util method 2023-01-16 10:10:01 -08:00
Eric House
c620f9bc75 Don't allow comms types that aren't in selfAddress
(Likely crashes on android)
2023-01-15 16:18:26 -08:00
Eric House
a02ea95600 remove dead code: game_reset and friends 2023-01-11 12:28:09 -08:00
Eric House
a5b0f3dd20 add debug-only code to check for thread-safety 2023-01-06 07:53:10 -08:00
Eric House
df5da2c4aa add assert toward removing (redundant) method 2023-01-05 21:53:22 -08:00
Eric House
3921da97b9 use new topic format for invitations too 2023-01-05 21:53:22 -08:00
Eric House
4caf660c1c cleanup 2023-01-04 14:13:53 -08:00
Eric House
16ced1dd49 fix linux compile; log gameID as %X everywhere 2022-12-30 16:15:03 -08:00
Eric House
837991feb4 remove timestamps from mqtt header and procs that feed it
It belongs in comms msg header. Also remove PROTO_2, which shipping
code can read but never could send.
2022-12-30 15:35:01 -08:00
Eric House
310e1cea4f remove bad assert 2022-12-30 15:35:01 -08:00
Eric House
550248bce0 fix assertions from missing timestamps 2022-12-29 22:39:26 -08:00
Eric House
bba8e99098 require that timestamp be set
MQTT must create the same header for each message, so having it set
the current timestamp is bad. I actually think it belongs in the comms
header, not in each transport.
2022-12-29 21:24:59 -08:00
Eric House
2942c140ee consider channel when deciding if a game's present (and fix assign)
Rematch against self didn't work, and is useful for testing. So in
dutil method hasGame(), check if games with the same gameID are also
for the same channel. And when creating a new game for rematch, make
sure it's channel is 0.
2022-12-29 21:21:39 -08:00
Eric House
ae9d576bad fix crash when 0-length mqtt buffers arrive
Which is what happens when you "clear" retained messages
2022-12-28 23:21:32 -08:00
Eric House
fdbd404f37 cleanup 2022-12-27 17:38:20 -08:00
Eric House
9e675d49ba log info about an assert I've seen 2022-12-26 20:30:46 -08:00
Eric House
6648a25dd0 tweak logging 2022-12-26 19:24:39 -08:00
Eric House
5fe02a0888 set initial flags to reflect new version for invites
Creating an address record without having heard from the remote is
new, and setting it to an old version was preventing using new msg
format. So set to new by default. Not sure how it'll get downgraded
facing an old client, but a 100-game upgrade test passes.....
2022-12-21 16:11:55 -08:00
Eric House
5887140d9b use hex for gameID in games list; fix compile error 2022-12-21 10:38:31 -08:00
Eric House
9b1fe83b61 fix to compile without DEBUG set 2022-12-21 10:29:48 -08:00
Eric House
7764c17705 resend all even if some unsendable
Looks like invitations become unsendable before they're deleted
sometimes and so block sending real messages. This fixes device
accepting invitation but never hearing back from host.
2022-12-21 10:21:41 -08:00
Eric House
933da2de07 API cleanup and all done
This should complete sending to multiple topics (for backwards
compatibility) and supporting combined messages in the future (sending
them is hard; receiving not so much.)
2022-12-20 11:55:30 -08:00
Eric House
6b029d5a85 invitations work on linux 2022-12-20 09:20:02 -08:00
Eric House
af4e39d921 snapshot: new mqtt msg format allowing multiple messages 2022-12-19 19:53:57 -08:00
Eric House
b179a0bade remove dead code 2022-12-18 18:50:05 -08:00
Eric House
3b6132d8a1 remove stuff that wasn't meant to get pushed 2022-12-18 16:21:51 -08:00
Eric House
096c13614a use ifdefs to go back to using only old-style per-device topics 2022-12-18 16:17:05 -08:00
Eric House
cf2d49e249 more 2022-12-18 10:23:36 -08:00
Eric House
d799b94169 use persist flag and new per-game mqtt topics (too)
I didn't understand MQTT at all. Per the docs anyway it only keeps a
message around if its "persist" flag is set, and then it only keeps
the most recent per topic. I expected that when a device connected,
messages would be waiting for it, but that's apparently not true (some
evidence to the contrary.) But having all games on a device share the
same topic means only one message can be waiting. So switch to
including gameID in the topic, subscribing to a wildcard topic and
sending to a different one per game. For now, for legacy purposes,
we'll keep sending to the old per-device topic.
2022-12-16 14:35:22 -08:00
Eric House
53e1a68d6d track, and offer to display, comms-sent invites like others
I'm only keeping the most recent since they're sent every time a game
opens, app launches, etc.
2022-12-10 22:17:14 -08:00
Eric House
aea7c3fd92 always save known player game start time
Was only saving it in case of conflict, which is rare
2022-12-06 07:45:10 -08:00
Eric House
a2806f1c3f show known player name of missing host
This is for debugging use only for now, but it's useful when a host
seems non-responsive to know which it is.
2022-12-05 21:21:46 -08:00
Eric House
3e32fdb840 sort words using blanks behind those not
Engine shouldn't be so stupid as to play a blank for 0 points. So when
comparing two moves, sort first on score, then use number of blanks
used to break any ties.
2022-11-24 08:25:40 -08:00
Eric House
34f68a435b include game name in nli when rematching 2022-11-18 21:52:10 -08:00
Eric House
0141f110be fix to compile without DEBUG set 2022-11-18 11:09:22 -08:00
Eric House
92b02fccb7 cleanup 2022-11-18 11:09:22 -08:00
Eric House
86303475af fix assertion firing when relay address still present 2022-11-18 11:09:22 -08:00
Eric House
f2b034d710 recognize in-comms invites when opening incomplete game
Android offers to invite when it thinks no invitations have been
sent. Now it knows about those buried in comms.
2022-11-18 11:09:22 -08:00
Eric House
6f57665da2 pass number of pending comms invites into informMissing() 2022-11-18 11:09:22 -08:00
Eric House
e8d2c4d600 add channel to nli logging 2022-11-18 11:09:22 -08:00
Eric House
924695d3fb add new stream version that skips relay and allows longer string
And remove some dead code
2022-11-18 11:09:22 -08:00
Eric House
12d8a092d7 move getUsername() to dutils to avoid crash
Being in util meant the default implementation got called, and that
returned a null string: boom.
2022-11-18 11:09:22 -08:00
Eric House
be9d80533e cleanup and add helper functions
Looking toward a time when channelNo's high-order bits ensuring the
right device is receiving messages go away.
2022-11-18 11:09:22 -08:00
Eric House
e960877256 more 2022-11-18 11:09:22 -08:00
Eric House
066232d234 more stuff 2022-11-18 11:09:22 -08:00
Eric House
f2809e6e15 start of getting rid of gameID part of channelNo
Don't seem to need it post-relay, and it complicates things when
invitations are messages too.
2022-11-18 11:09:22 -08:00
Eric House
9a7946de36 fix stall showing up in curses test app
Duplicate messages early on, which happened only in the test script
but could have anywhere, broke connectivity. So don't kill address
records when a duplicate shows up. Dupes only escape message ID
checking early (before channel is established). I used to remove
address records when a message was rejected, but don't understand why
so removed that, though asserts show it's not mattering except for
those early messages.
2022-11-18 11:09:22 -08:00
Eric House
4cfc781cd7 remove assert (until I figure out why firing) 2022-11-18 11:09:22 -08:00
Eric House
f2b707ed4d add assert to test where param is unnecessary 2022-11-18 11:09:22 -08:00
Eric House
75eaadaddb cleanup -- belongs on main 2022-11-18 11:09:22 -08:00
Eric House
5a5a8e7db8 make games connect after creation from invitation 2022-11-18 11:09:22 -08:00
Eric House
3923a2d9a6 check for duplicate invites; don't create if found
Add dutil proc haveGame() and use it to detect duplicate
invitations. I'm passing, but ignoring on android, the channel, which
means that for now you can't invite yourself and on-device testing
requires having CrossWords and CrossDbg or a second user.
2022-11-18 11:09:22 -08:00
Eric House
980ba68297 fix stuff crashing android 2022-11-18 11:09:22 -08:00
Eric House
7587653541 fix memory leaks; get curses using new invite resp. code 2022-11-18 11:09:22 -08:00
Eric House
766554d3f5 snapshot: rematch and invitation handling most work from common
But curses will crash, duplicates and missing dicts aren't handled,
etc.
2022-11-18 11:09:22 -08:00
Eric House
8a64d53f61 cleanup 2022-11-18 11:09:22 -08:00