Commit graph

74 commits

Author SHA1 Message Date
John "Elwin" Edwards
7332b95a30 Add server-side support for watching dgamelaunch games. 2015-01-13 20:30:10 -05:00
John "Elwin" Edwards
56024418c3 Fix further crashes when following dgamelaunch games.
The crashes apparently resulted from reading a ttyrec header and
then trying to read the data chunk before dgamelaunch produced it.
When the data chunk did become available, it would be read by the
header function.

The simplest solution was to store the position for reading the
ttyrec file in the DGLSession, and to leave it unchanged if anything
unexpected occurs when reading.
2015-01-12 17:10:35 +00:00
John "Elwin" Edwards
60b83c4944 RLGWebD: fix simultaneous watcher bugs.
WebSockets should now only receive the intended data, no matter how
many of them there are or what they are doing.  They should...
2015-01-10 18:54:55 -05:00
John "Elwin" Edwards
6373e70361 RLGWebD: fix simultaneous player bug.
Multiple games can now run at the same time, and data will be sent to
the proper place.  The interaction of multiple players with watchers
has not yet been tested.
2015-01-09 13:06:41 -05:00
John "Elwin" Edwards
ef4cb9ac8d rlgwebd.js: clean up TermSession parameters.
Use the player name instead of a login key that has already been
verified and resolved to a player name.
2015-01-09 09:43:21 -05:00
John "Elwin" Edwards
ee8782bbf4 Remove the TermSession 'open' event.
Failure is now signaled with a TermSession.failed flag.

Playing two games at the same time no longer causes crashes, but it
does send the same output to both players.
2015-01-09 08:55:38 -05:00
John "Elwin" Edwards
2369fa45d4 Rename watcher to dglwatcher. 2015-01-07 13:49:37 -05:00
John "Elwin" Edwards
3c88c233b4 rlgwebd.js: prevent races when reading ttyrecs.
DglSession objects read a 12-byte TTYREC header, extract therefrom the
length of the data chunk, and then read the data.  In between these two
reads, the file watcher could trigger another readchunk() invocation,
which might attempt to read a header from the beginning of the data
chunk.  This usually results in expecting a data chunk of several GB
and failing to create a Buffer for it.

The race is remedied by setting a flag on the DglSession object
whenever readchunk() is called, clearing it when both reads complete,
and refusing to read if it is already set.
2015-01-07 13:18:35 -05:00
John "Elwin" Edwards
547387846f rlgwebd.js: read ttyrecs created by dgamelaunch.
TTYREC files created by dgamelaunch are tracked by DglSession objects,
as a first step toward making them watchable.
2015-01-06 16:59:12 -05:00
John "Elwin" Edwards
2064d2a9e6 RLGWebD: overhaul the list of current games.
The /status WebSocket now only sends a complete list when opened.  At
40-second intervals, it sends a list of games that have been updated in
the last minute.  The client now uses this to keep its own list.
2015-01-04 16:55:57 -05:00
John "Elwin" Edwards
7e294b2136 Properly print session tags in the log.
They are Strings and should not be formatted with %d.
2015-01-03 20:07:42 -05:00
John "Elwin" Edwards
abb4ba8f31 RLGWebD: Clean up code related to session timestamps.
TermSessions now store the timestamp of the latest data.  This removes
the need to use fstat() to calculate idle times.

The reaper() function is removed.  It may be useful to find another way
to remove old login keys.
2015-01-03 17:39:15 -05:00
John "Elwin" Edwards
c7fc6418ff RLGWebD: excise polling.
WebSockets are supported nearly everywhere now.

Listing current games and watching them are still broken.
2015-01-03 15:23:04 -05:00
John "Elwin" Edwards
920c6e8829 rlgwebd.js: get rid of numerical game identifiers.
Games will be indentified by gamename/username pairs.  This will allow
better interoperability with dgamelaunch.

Polling clients are no longer supported; the code remnants need to be
removed.  The reaper() function will likely crash.  Unexpectedly, the
WebSocket client still works well enough to play.  Watching and listing
current games are probably broken.
2015-01-01 15:56:22 -05:00
John "Elwin" Edwards
0a0f754135 Use posix.getpwnam() to look up UID/GID to drop to.
This is more reliable than hardcoding the numbers.
2014-05-12 08:59:47 -07:00
John "Elwin" Edwards
2e5e5d02da Keep a list of dgamelaunch games and put it in the /status message. 2014-04-01 16:43:35 -07:00
John "Elwin" Edwards
f605244ae6 Begin support for watching dgamelaunch games.
watcher.c is a subprocess which uses inotify to watch the inprogress
directories.  A C program is used because node's fs.watch() can't tell
the difference between creation and deletion.
2014-04-01 11:23:25 -07:00
John "Elwin" Edwards
668f6d246d Check that the ttyrec stream has an fd before passing it to fstat.
The stream might not have an fd, presumably if the open isn't complete.
Calling fstat then causes crashes.
2014-01-06 09:11:35 -05:00
John "Elwin" Edwards
cf4fd96592 RLGWebD: game binaries have moved to /usr/bin. 2013-10-28 22:11:14 -07:00
John "Elwin" Edwards
b760c1d444 RLGWebD: inprogress dirs have moved 2013-10-20 19:26:39 -07:00
John "Elwin" Edwards
49640d131e RLGWebD: use NODE_PATH to find modules. 2013-08-14 08:04:36 -07:00
John "Elwin" Edwards
fabaea6849 Replace the daemon module with posix.
The daemon module doesn't include chroot() anymore, so a replacement
is needed.  Detaching a daemon keeps getting harder to do in Node, so
some setup has been moved into a shell script.
2013-07-20 12:23:53 -07:00
John "Elwin" Edwards
363c88f00f Logins don't time out anymore.
No more login timestamps either.
2012-09-12 15:48:41 -07:00
John "Elwin" Edwards
47cc4d29b6 RLG-Web server: allow changing e-mail and password.
Logged-in users can change their e-mail addresses and passwords with a
POST to the /uinfo interface.
2012-08-26 19:04:57 -07:00
John "Elwin" Edwards
48b5b5d32a Improve the /uinfo interface.
Change the URL scheme to /uinfo/<property>?key=<key> because that makes
more sense.
2012-08-25 19:33:31 -07:00
John "Elwin" Edwards
81e772545a Add a user information interface at /uinfo.
User information can be retrieved at /uinfo?key=<login key>&<prop>.
The only property currently retrievable is email; eventually these will
also be settable via POST.
2012-08-13 09:07:28 -07:00
John "Elwin" Edwards
51978efd4e Correct the clear sequence for srogue.
rlgwebd sets TERM to xterm-256color, which uses CSI H CSI 2J to clear
the screen.  The description of srogue had been CSI H CSI J, which is
the sequence for screen.
2012-08-11 21:30:12 -07:00
John "Elwin" Edwards
e4ce0b48a3 Add support for Advanced Rogue 5. 2012-08-11 19:48:25 -07:00
John "Elwin" Edwards
2f37cf2d94 RLG-Web server: update timestamps for WebSocket games.
The login timestamps will now be refreshed when games are started via
WebSockets or stopped.
2012-07-16 10:09:57 -07:00
John "Elwin" Edwards
f7f56fedae RLG-Web: improvements to choices and status messaging.
Server-side, have gamemux 'end' events include the name and game, so
they can be sent to WebSockets connected to /status.  This means a
WebSocket client only needs to update its choice list when it gets a
begin or end message with its own username.  So it only needs to check
/pstatus/<name> at those times and can stop polling.
2012-07-16 08:23:51 -07:00
John "Elwin" Edwards
a0be18657b Replace taking over games with forced saves.
Instead of reusing the id, just SIGHUP the game process.  This works
whether it is using polling, WebSockets, or dgamelaunch.
2012-07-15 22:33:44 -07:00
John "Elwin" Edwards
a847191450 RLG-Web: fix lockfile mixup.
Put the terminal dimensions into the lockfile in the proper order.
2012-07-15 21:03:36 -07:00
John "Elwin" Edwards
854519a7bd RLG-Web: improve taking over sessions.
WebSocket sessions should not be taken over, and polling sessions are
not yet convertible to WebSockets.  Eventually the current method of
taking over via Player#reset() should be replaced with autosaving the
game, which will always work.
2012-07-15 20:30:33 -07:00
John "Elwin" Edwards
d11eb5e22a RLG-Web server: add playing through WebSockets.
Games can be played with a WebSocket connection to
/play/<game>?key=<loginkey>&w=<cols>&h=<rows>
2012-07-15 09:04:39 -07:00
John "Elwin" Edwards
bec02aea9e RLG-Web server: send status events over WebSockets.
A WebSocket connection to /status will be sent periodic listings, along
with notifications of the beginning and end of games.
2012-07-13 22:26:20 -07:00
John "Elwin" Edwards
4174840c3e RLG-Web server: refactor statusmsg() to work with WebSockets.
Separate the game-listing and http-responding components of statusmsg()
so the listing function can be reused for WebSockets.
2012-07-13 09:17:05 -07:00
John "Elwin" Edwards
031bc239f8 RLG-Web server: code cleanup.
Delete some TermSession code left over from the first attempt at
Websockets.  Also don't bother logging the disconnection of watchers
after the game has ended.
2012-07-13 08:52:17 -07:00
John "Elwin" Edwards
f4c4f5e0f1 RLG-Web: Complete the WebSocket watcher.
Watching via WebSockets now takes into account terminal size, player
name, etc.
2012-07-13 08:39:39 -07:00
John "Elwin" Edwards
aee00a29d5 RLG-Web: begin converting to WebSockets.
Use WebSockets for watching, if the browser supports it.  Functionality
is not complete yet.
2012-07-12 22:16:15 -07:00
John "Elwin" Edwards
2828b5f33c RLG-Web: Allow games to be taken over.
Make it possible to reconnect to a game if the user has left the page
without saving.
2012-07-11 10:30:33 -07:00
John "Elwin" Edwards
24879b8123 RLG-Web: improve game-starting messages.
Include the name of the player and game when watching or playing.
2012-07-10 16:32:49 -07:00
John "Elwin" Edwards
06614ac0aa RLG-Web: make /pstatus/* differentiate between dgl and RLG-Web games.
The /pstatus/ API now responds with "p" for games being played in
RLG-Web and "d" for games being played in dgamelaunch.
2012-07-09 12:51:12 -07:00
John "Elwin" Edwards
9c45f52722 RLG-Web: use the pty module.
Convert the RLG-Web server to use the pty.js module instead of the
ptyhelper binary.
2012-07-09 12:24:03 -07:00
John "Elwin" Edwards
286626df57 rlgwebd.js: Unlink control socket at startup.
Unlinking at shutdown doesn't work because at that time, the process is
chroot'ed and unprivileged.
2012-07-08 17:49:43 -07:00
John "Elwin" Edwards
d0ea0471c0 rlgwebd.js: set the width and height on Player objects.
Fixes the client not being informed of the pty size.
2012-07-08 08:40:08 -07:00
John "Elwin" Edwards
e3dd70ce08 Switch to node v0.8.
In node v0.8, path.exists() has been moved to the fs module.
2012-07-08 08:02:17 -07:00
John "Elwin" Edwards
2d9c8bd011 Display idle time of games in progress.
statusmsg() now includes games' idle times, and the client displays
them using getcurrent().
2012-06-20 11:37:05 -07:00
John "Elwin" Edwards
f711cdb591 Some status improvements.
Status messages now consistently use the game's uname, and the table
of choices puts the games in the right order.
2012-06-20 08:49:10 -07:00
John "Elwin" Edwards
674f570b63 rlgwebd.js: fix failure to respond.
The codepath for a watcher requesting to quit did not lead to any
response being sent.
2012-06-20 07:37:15 -07:00
John "Elwin" Edwards
5f914901d1 Make sure watchers start with completely drawn screens.
TermSessions now buffer all data since the last screen clear, so new
Watchers can start with complete screens.
2012-06-19 19:11:59 -07:00