Commit graph

166 commits

Author SHA1 Message Date
Eric House
f072c68bf9 bring in changes from relay_via_http branch
It's time to make them live so client development can use a live relay,
and all the old tests pass, so why not.
2017-11-12 20:25:29 -08:00
Eric House
6f0fb66a0d fix three-year-old huuuuge memory leak
Hadn't run Valgrind in a while. There's another too, but much smaller
and harder to track down.
2017-06-07 08:07:42 -07:00
Eric House
f06e7bdd98 don't drop duplicate reconnect
When Android client is backgrounded with a game playing (BoardActivity
on top) then brought to front again it fails to reconnect to relay
because it didn't disconnect and the relay thinks it's still there. The
right fix is in making the java code do the right thing (complete
disconnect), but it seems harmless to just honor the reconnect in this
case. Doesn't even cause leaks, per valgrind.
2017-06-06 06:27:58 -07:00
Eric House
9cd76d887d fix weird double-bang thing 2016-11-09 07:45:39 -08:00
Eric House
d468866a01 no more variables called socket; all are "sock" now. 2015-11-20 23:15:04 -08:00
Eric House
26b01acf23 fix crash on duplicate connect packet: drop it, but keep the
connection alive if the duplicated packet set up addressing correctly.
2014-12-15 16:42:34 -08:00
Eric House
92fd048eef signature change: return void instead of always returning true 2014-12-15 15:33:12 -08:00
Eric House
2e9c033a29 If client provides its index, honor that when placing it in game. This
allows a game where indices have already been established over some
transport other than relay to start using the relay mid-game.
2014-12-10 08:03:39 -08:00
Eric House
b43855a313 fix curses build for 64bit compile and to use common layout (meaning
tray is now under the board unstead of to the right).  Works on 64-bit
system at least for non-networked games.
2014-01-05 13:04:59 -08:00
Eric House
91b54dd66a use delete to free what's allocated using new 2013-10-25 06:16:17 -07:00
Eric House
c1f94681bb when a message sent via udp from cref isn't acked, add it to stored
messages so gcm loop can pick it up.
2013-09-26 07:14:24 -07:00
Eric House
5d49b9b5d6 oops: don't default to clearing relayid 2013-09-18 08:04:12 -07:00
Eric House
2629c07256 Address problem with devids (e.g. GCM): until now when you got a new
devid you tossed your relayID and reregistered.  Which meant any
existing messages meant for your relayID were orphaned, and any open
games didn't know who they belonged to until you reconnected to them
with your new relayID.  So: modify the UDP protocol (though not on
Android yet) to include both relayID and devid with registration, with
one or the other an empty string if not present or not changed from
earlier.  I can't fix existing clients that are dropping their
relayIDs, but when one does a re-connect without a relayID I can look
it up from the existing game record, then reuse it rather than issue a
new one.  Better than nothing -- and that protocol will be obsolete
soon anyway.
2013-09-14 21:06:14 -07:00
Eric House
d9bfc01e35 change unsigned char to uint8_t (using sed) 2013-08-29 22:55:11 -07:00
Eric House
0e6b211a76 fix treating game-targeted messages as if they were device-targeted.
Should probably have separate tables for the two types....
2013-08-29 06:37:22 -07:00
Eric House
cd2b83c9c5 type change: use vector<uint8_t> rather than string in struct for
retrieving data from db.
2013-08-28 20:33:42 -07:00
Eric House
16aafccec6 to telnet interface add ability to forget device and to send to one
not known (which will make message available next time it connects or
via GCM); rename methods.
2013-08-22 06:29:20 -07:00
Eric House
23a59e8097 sometimes a device goes away and we don't notice, so when it comes
back just reuse its record rather than asserting there's no record
there.
2013-08-21 21:32:55 -07:00
Eric House
f1b60dab62 Don't assert when can't find state transition. At least in some cases
these result from unexpected/out-of-order packets that slip through.
2013-08-14 08:11:21 -07:00
Eric House
fe51d19c2e Device can't be 'alreadyHere' if has hostID of 0 since the only way a
device gets registered involves giving it a non-0 hostID.  Fixes array
OOB access.
2013-08-14 08:10:09 -07:00
Eric House
80f66d1df7 remove test for duplicates now that it's impossible 2013-08-13 08:20:57 -07:00
Eric House
5be8779749 remove redundant member variable 2013-08-13 08:19:32 -07:00
Eric House
c9406c36ae use a simple array rather than a vector to store currently connected
devices.  It's simpler, searching for hid is faster, and it makes it
easier to detect when we try to add the same device twice.
2013-08-13 08:04:19 -07:00
Eric House
cd9eea665b oops: still need to register device connecting via tcp so gcm sends
can work.
2013-08-07 21:36:06 -07:00
Eric House
b49486fc3f cleanup: use constant and add/use isUDP() 2013-08-07 21:31:10 -07:00
Eric House
bac947d780 don't remember tcp-based addresses. Fixes problem when a device
switches from tcp- to udp-based connection.
2013-08-07 21:04:05 -07:00
Eric House
470dbb5304 oops: still remove address from set tracked if it's not tcp 2013-08-05 07:50:11 -07:00
Eric House
4ad6696ecc add delete-on-ack logic to another message sending site, and fix
assertion failure caused by not providing a client token on messages
being sent.
2013-08-02 22:33:06 -07:00
Eric House
5f9b2e431f optimization: test address before fetching messages for it 2013-07-28 07:28:32 -07:00
Eric House
9951064439 fetch all stored messages at once to reduce number of DB calls made. 2013-07-25 06:37:53 -07:00
Eric House
32150049e2 assert that we aren't tracking two connected games with the same hid 2013-07-20 06:28:35 -07:00
Eric House
1d5cf0bea7 don't remember devid unless it's valid 2013-07-17 21:33:36 -07:00
Eric House
b5714e9d14 improve API: hide special numbers inside implementation 2013-07-12 08:24:44 -07:00
Eric House
2cd84c4229 test that address is good each time through loop 2013-07-05 08:03:03 -07:00
Eric House
649969bc30 send ALL_HERE to all players 2013-06-25 22:52:13 -07:00
Eric House
d4cf37d2ef fix misspelling 2013-06-24 07:05:09 -07:00
Eric House
c1cc11866f tweak logging 2013-06-22 05:54:32 -07:00
Eric House
2a35fac1e8 rather than invalidating socket in AddrRec when it's closed, add a
timestamp set when it's opened.  Older copies with the same socket can
be tested against the cannonical copy maintained by tpool and sending
avoided when the timestamp shows the endpoint has likely changed.
Change tpool's list of sockets to a map for faster lookup, and get rid
of similar structure in udpqueue.
2013-06-21 06:05:26 -07:00
Eric House
11d299606e test for socket == -1 (invalidated) before sending 2013-06-20 07:10:09 -07:00
Eric House
5e0fd89c9e update with all relay/ changes from gtk_multigame. This is what the
live relay's running anyway.
2013-02-04 06:08:39 -08:00
Eric House
98679c8363 cleanup: better encapsulation for AddrInfo 2013-01-13 10:14:06 -08:00
Eric House
c567647a8d get rid of mapping of socket->game_connection, which will not work
once UDP sockets and/or per-device (not per-game) connections come
along.  Lots of changes, most not involving code flow but a couple
that did.  So far two gtk games can connect and exchange moves.
Haven't tested reconnection or store-and-forward.
2013-01-12 16:09:24 -08:00
Eric House
1316ae4b67 Fix relay devid protocol to deal with case where client submits a
ID_TYPE_RELAY id that's not in the devices table (as has happened when
a device switches relay URLs during testing, but might also happen if
I have to delete an entry from the devices table.)  In that case,
return ID_TYPE_NONE to the client, which will be its clue to delete
its ID_TYPE_RELAY id and submit the platform-specific id again.

Note: android won't compile this revision thanks to util.h change
2012-11-10 15:05:44 -08:00
Eric House
f1ee77882b Send devid with RECONN as well as CONN so games present when device
upgrades can also use GCM.  Tested on relay but not device.
2012-11-09 06:54:12 -08:00
Eric House
59937b8514 modify how devids are handled on the relay and the protocol through
which they're communicated to the device.  Device is expected to have
a platform-specific notion of ID which the relay stores in a new
devices table and indexes with a 32-bit number which is returned to
the device -- which is encouraged but not required to use it in lieu
of the longer ID in future communications.  Modify linux client and
test script to use the relay-supplied id.  Some of this is commented
out for now.
2012-11-03 10:58:01 -07:00
Eric House
3469975d2a add, still disabled by compile-time flags, code to transmit device ID
(e.g. ID Android devices get via GCM) to relay and to associate it
there with messages that need to be delivered.
2012-10-30 07:01:47 -07:00
Eric House
866aeb2387 change relay connect message format to include client version (meaning
of which is TBD).  When a new-version client connects, store the value
it's passed. At first this will let me track how quickly people
upgrade.  Later I can use it to let different clients have different
formats to their messages e.g. to proxy.
2012-01-26 05:43:54 -08:00
Eric House
caa40fa023 store most recent IP address each device has come in on. Requires new
column in db.  Not really used yet but interesting to watch....
2012-01-04 18:14:12 -08:00
Andy2
0d4e839dba log an error and drop bad fwd packet rather than assert 2011-12-07 18:43:13 -08:00
Andy2
30145deba7 add new proxy message handler for no-conn message, and feed into
existing store-and-forward system.  With this checkin a robot-vs-robot
game plays for quite a few moves without either game every loaded into
the foreground (via a BoardActivity instance on Android), with all
moves transmitted as a result of relay checks.  One of the games
refuses to open later, however, and there are certainly other bugs.
And I'm not sure what happens when a message sent no-conn (without a
cookie ID) is received in the foreground.  But this is progress.
2011-08-16 19:41:33 -07:00