Commit graph

63 commits

Author SHA1 Message Date
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
John "Elwin" Edwards
1ffb72866a RLG-Web: make multiple watchers possible.
Split the TermSession class into the new TermSession, which handles the
PTY, and client classes, which handle HTTP sessions.  These are Player
and Watcher.  This allows multiple watchers per game, and other
improvements.
2012-06-18 13:43:51 -07:00
John "Elwin" Edwards
c7cb905b29 RLG-Web: delay removing TermSessions until the client is informed.
Add a TermSession.sendq flag that indicates whether a type q message
has been sent to the client.  Don't immediately destroy the TermSession
on child exit if the message hasn't been sent.

This is an ugly hack until the TermSession class is separated into an
EventEmitter to handle the PTY and a listening object that handles
communication with the client.  That will also allow other clients to
watch the game.
2012-06-11 09:15:33 -07:00
John "Elwin" Edwards
20d72fc066 RLG-Web: make login sessions time out.
After enough inactivity, log the user out automatically.
2012-06-09 21:20:14 -07:00
John "Elwin" Edwards
a00bd32552 rlgwebd.js: remove some debugging.
Remove some residual debugging lines.
2012-06-09 13:04:46 -07:00
John "Elwin" Edwards
43f30438ed rlgwebd.js: add a player status interface.
Give information on a player's current status at "/pstatus/<name>".
Also fix some shift()/unshift() confusion in checkprogress().
2012-06-09 11:46:58 -07:00
John "Elwin" Edwards
e0a70e4b0e rlgwebd.js: refactor some game-starting code.
Separate things like checking for games in progress, starting a new
game, and figuring out where the lockfile and ttyrec should go.  This
allows e.g. the games-in-progress check to be used to create status
messages.  It also keeps the argument list for the TermSession
constructor to a sensible size.
2012-06-08 18:11:47 -07:00
John "Elwin" Edwards
012c86faa8 RLG-Web: separate logging in and starting a game.
The user now logs in with a username and password, receiving a token
which is then used for any actions requiring authentication.  Starting
a game is one such action.  Games use a different set of id keys.
This allows users to supply their passwords once and then play any
number of successive games.  Also, newly registered users do not need
to supply their passwords again.
2012-06-07 15:43:06 -07:00
John "Elwin" Edwards
fbc86e7e12 rlgwebd.js: remove dead code.
Remove functions that dealt with HTML forms and other obsolete code.
2012-06-06 10:08:31 -07:00
John "Elwin" Edwards
07c7ea3515 RLG-Web: autosave idle games.
If a game has been idle for too long, close it.
2012-06-06 10:01:18 -07:00
John "Elwin" Edwards
dec7bc108a rlgwebd.js: handle HTTP HEAD properly.
Prevent a message body from being sent in response to HTTP HEAD.
2012-06-05 20:13:47 -07:00
John "Elwin" Edwards
e0bbee0242 rlgwebd.js: add a status interface.
The RLG-Web server now makes its status and the list of current games
available to a GET on /status.
2012-06-05 14:51:42 -07:00