Commit graph

153 commits

Author SHA1 Message Date
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
Andy2
928404be50 remove unused enum 2011-07-06 06:15:25 -07:00
Andy2
f3a4ff9dfc use cid for variables of type CookieID everywhere instead of almost
everywhere
2011-06-29 18:42:41 -07:00
Andy2
cdc16ee974 variable/method name change only: cookieid->cid 2011-06-25 15:43:52 -07:00
Andy2
38ad3aa81c cleanup; and: collapse HostRec and socket set into map of socket to
HostRec, protecting all accesses with ReadWrite locks.
2011-06-25 15:40:12 -07:00
Andy2
6c121dac57 final set of changes -- all test cases now seem to be passing. Stop
duplicating set of sockets owned by a cref, moving it from cinfo into
cref and caching a copy outside when cref is unclaimed (after which no
change is possible until it's claimed again.)
2011-06-24 18:34:34 -07:00
Andy2
63a4e6c953 get rid of per-cref mutex: it's redundant now that access is
synchronized.  Add method to check if new players are still welcome to
allow fix for race.
2011-06-23 18:57:48 -07:00
Andy2
e886a1aefe lots more changes -- another snapshot, this, rather than stuff
carefully polished and reviewed.  Shows progress, though, in getting
through tests.
2011-06-23 07:12:50 -07:00
Andy2
3ebcc01e86 beginning -- this is a snapshot -- of rewrite of how relay keeps
multiple thread out of a single game.  Add new class that locks
per-cid and start using it.  Very incomplete.
2011-06-22 06:51:26 -07:00
Eric House
85d484a881 major mod to deal with devices that fail to receive ACK and then
reconnect.  I was putting both (i.e. the same device twice) in the
same game.  Now I detect this based on the seed being duplicated and
treat the device as having failed to ACK then proceed with the CONNECT
as if it were new.  Tested pretty heavily but only with two-device
games.
2011-06-20 18:13:15 -07:00
Eric House
27346cf58b change AIP to remove several stored messages at a time. Will use
later to delete messages after proxy fetches and ACKs them so traffic
isn't repeated.
2011-03-31 18:15:03 -07:00
Eric House
720f78d18a get rid of ivars used only for http UI 2011-01-04 21:43:10 -08:00
Eric House
4bd5553596 track mtime per host rather than per game -- make it an array in the db. 2010-12-01 21:08:22 -08:00
Andy2
2c9f2572a8 use GameFull() 2010-11-15 06:48:57 -08:00