Commit graph

67 commits

Author SHA1 Message Date
Eric House
5bd71ba7c5 put cids back into the database
The hack I came up with for storing them in memory isn't working. Even
if it's just that I don't understand C++ maps they need to be cleared
when the DB's wiped (my favorite test these days) and I don't want to
spend the time now.
2017-11-11 18:46:02 -08:00
Eric House
7c22d1fdf8 fix failure of http apps to ack relay
Change how acks are handled by adding ability to look up connname by
combination of hid and token. It's a bit of a hack, but it's already
there in the protocol and enough to find the game.
2017-10-28 16:29:04 -07:00
Eric House
e3b2a0e4e1 fix misbehavior by new in-memory map
I don't know why what I was doing didn't work, but removing access via
[] and using iterators passes all the asserts I could throw at it.
2017-10-28 15:01:31 -07:00
Eric House
3645331061 pass hid in to db function getting per-dev info
Somehow I've been failing to treat this column as an array for some
time. I don't have any test cases that failed but it was clearly
wrong. Test cases still pass....
2017-10-25 20:33:25 -07:00
Eric House
6e06fdea07 stop storing cid in database
It's a runtime-only thing, explicitly removed from db on boot. So add a
map from connname->cid to the dbmgr class and modify that rather than a
column. Passes discon_ok2.sh tests as long as use-http stuff isn't on.
2017-10-25 19:56:56 -07:00
Eric House
cc54621e45 store message first, remove on ack 2017-10-25 05:51:45 -07:00
Eric House
37ecd81c04 change param names
about to introduce a second. This will make things clearer. No code
change here though.
2017-10-10 20:17:36 -07:00
Eric House
67f4e4475c manual bring-over of relay changes for invite support 2015-07-11 08:08:22 -07:00
Relay User
9c7213e42b Make it possible to launch relay early in machine boot cycle before
postgres is running (e.g. from a @reboot shortcut in a crontab) by
having it wait, sleeping periodically, until a connection is
available. Requires new flag be passed into main.
2015-07-11 07:04:24 -07:00
Eric House
19573af533 a more elegant way of building up params to pass to PQexecParams 2014-04-25 18:45:51 -07:00
Eric House
6eaf7a57b5 fix crash when there's a "'" in model name 2014-04-25 07:41:58 -07:00
Eric House
8862c5f750 move include file up 2013-09-24 08:37:18 -07:00
Eric House
af44c6d190 only append to mtimes when appending a new devid 2013-09-15 12:54:47 -07:00
Eric House
c212c0e367 add in-memory cacheing of messageless-connname/hid combos. 2013-09-15 10:04:46 -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
c115752852 supply in linux client, and look for and store on relay, os version 2013-09-07 16:17:31 -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
063b01d3d8 change most len-as-short+bytes strings to vli+bytes; add device model
to what's passed for device registration, and store it in a new column
in devices table.
2013-08-25 21:20:26 -07:00
Eric House
2157706dcd add client version and a desc string to devices DB and to reg info sent to relay 2013-08-20 08:09:45 -07:00
Eric House
47203437cc register devices more often; add ctrl command to send text message to
device if possible, otherwise to post it to the db (mostly for testing).
2013-08-17 14:55:19 -07:00
Eric House
61009cefc7 in advance of using memcache, keep track (in memory) of those devids
for which no messages are pending, since that's a query that can be
made by each device every minute.
2013-08-15 07:24:30 -07:00
Eric House
a8cc920dcf new method 2013-08-01 07:49:12 -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
8e12a8ef84 when we get a fatal error from postgres server, try killing then
recreating the connection.  This is untested, as fatal errors are
rare.
2013-07-03 07:36:15 -07:00
Eric House
9138cd15b7 fix problems with devices reconnecting when their ACKs didn't arrive
and their slots are empty or have been reassigned: basically we check
if a device goes where it expects, and if not treat it as a new
connection rather than a reconnect, meaning its hostid may change.
Existing device code seems ok with that -- and at any rate I don't
think ACKs get dropped much in the wild.
2013-06-26 00:38:34 -07:00
Eric House
7ce939f5c0 pass rather than hard-coding column name 2013-06-17 06:48:22 -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
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
c847ec127e add and use function that does formatted printing to a std::string so
query buffers can no longer overflow.
2012-11-15 06:15:44 -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
adf49dffd7 init/take down thread local storage in constructor/destructor rather
than as static initializer (and then leaking on shutdown.)
2012-01-26 05:48:10 -08: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
b511b4c455 add new RecordSent to take list of msg ids -- and use stringstream
instead of static buffer and snprintf in one case.  May make sense
elsewhere too.
2011-08-17 18:07:21 -07:00
Eric House
d3108aac79 split method in two to provide new API (I'm not using yet) 2011-07-05 21:39:38 -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
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
Andy2
f96f4a040b add new proxy command that fetches actual messages stored for a device. 2011-01-22 12:52:26 -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
feca7345dc add GameFull -- database, not in-memory state, knows if game is full. 2010-11-15 06:48:36 -08:00
Andy2
0787a06eb5 accept new message from device announcing the death of a game
(including seed so it's harder to spoof); respond to that by setting a
DEAD column in the db and flagging the device as gone.  Notify any
connected device of the fact.  Refuse to accept new connections to
that game.  As already-connected devices reconnect, allow them to do
so but send a new status message that their game is dead.  Not heavily
tested yet.
2010-11-11 06:40:50 -08:00
Andy2
7cf4535b4c new dbmgr API returns number of players in game; use that rather than
currently connected devices to populate [RE]CONNECT message
2010-10-22 22:34:43 -07:00
Eric House
34df149046 include age of room with info returned for open public rooms 2010-10-14 22:16:21 -07:00
Eric House
86d73392d5 track bytes sent in db; use defaults to init ctime 2010-10-06 21:45:05 -07:00
Eric House
2e844d798f replace single db connection protected by a mutex with one connection per thread kept in thread-local storage. 2010-10-04 20:04:14 -07:00
Andy2
89f967a016 pass remaining reconnect params in case connName's missing from db.
Should only matter if the relay's db's been deleted.
2010-10-04 18:39:26 -07:00