Commit graph

58 commits

Author SHA1 Message Date
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
Eric House
d35bc7d748 refuse to store more than four messages at a time for a single
connName/hid pair.  This works around a problem where a device,
continuing to connect and send all pending messages for another device
that is not connecting, winds up with hundreds of identical messages
stored.
2010-10-03 18:18:15 -07:00
Eric House
bc65377cfd track device seeds in db. 2010-09-28 18:06:50 -07:00
Andy2
b0c6e6da9c add db method to count messages for connName/hid pairs and handle
query using it.
2010-09-24 05:50:02 -07:00
Andy2
eee41377f4 new methods for storing/retrieving messages in new db. 2010-09-23 06:31:29 -07:00
Andy2
85b4f3f075 move hostid assignment and tracking into db so it survives reboots and
recycling of crefs between when devices in a game connect.  This plus
movement of messages into the DB will re-enable games played without
the two devices ever being connected at the same time.
2010-09-23 05:33:27 -07:00
Andy2
e7b5923883 finish first pass at sending open public room names -- but with actual
list harvesting stubbed out.
2010-09-21 06:27:31 -07:00
Andy2
c5eef29bcc some suspicious crashes and subsequent reading say that multiple
threads can't share the same db connection.  So synchronize all
queries.  Multiple threads *can* access the db concurrently as long as
each has its own connection, so I could add connections to the tpool
threads.  But this will probably be performant enough for the first
10K simultaneous users. :-)
2010-09-16 20:08:32 -07:00
Andy2
1490b2def9 simplify state table, getting rid of a bunch of states: we never leave
ALLCOND until it's time to kill the cref.  When one device connects
and leaves the cref is recycled, so when a new device joins and is
assigned the same game and a new cref is initialized the number of
players already registered must be set from the db entry; do that.
2010-09-16 18:59:56 -07:00
Andy2
50c387d75e remove players from db as well as runtime when ack times out 2010-09-16 06:49:35 -07:00