Commit graph

23 commits

Author SHA1 Message Date
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
Andy2
2b702b48d6 need to clear CID of record in DB when killing corresponding in-memory
cref or reconnect will fail.
2010-09-16 04:47:17 -07:00
Andy2
a870cac86d break connect and reconnect into separate paths to simplify. Be
consistent: nJoined in DB tracks players "ever seen and issued
connName" rather than "currently connected".  Next step: debug game
between two devices never connected at same time.
2010-09-15 14:05:51 -07:00
Eric House
54d268b718 pass through to database whether room is public 2010-09-14 21:20:11 -07:00
Andy2
3b5b5f0241 factor dbmgr code; add and call method to zero CIDs on boot. 2010-09-15 01:14:28 -07:00
Andy2
f8c1c016cc remove special-case states and handling of first connect; track number
of players sought in the cref itself, adding in constructor, and not
in HostRec instances.  This is cleanup with no behavior change.
2010-09-13 13:49:13 -07:00
Andy2
ded6e22180 do finding of open games using database rather than cref list, which
requires updating the number of players when new devices join.  Drop
requirement that cid be unique.
2010-09-12 04:49:03 -07:00
Andy2
663551fcb5 improve db, adding uniqueness contraints. Pass in connName so can
meet that constraint.  Figure out next cid using a query at startup.
2010-09-12 03:57:23 -07:00
Eric House
87de53cf96 add new class to interface with postgres database in an experiment to
simplify things by using a db to survive a crash/reboot.  So far (with
next checkin) manages to update a db.  Next need to do queries instead
of searches through in-memory data.
2010-09-11 19:44:37 -07:00