Zombunity MUD: A distributed, message processing framework consisting of a message server, database http server and web client.
Clojure Other
Switch branches/tags
Nothing to show
Latest commit ec14406 Jul 30, 2013 @cwmaguire Updating to Clojure 1.5
Permalink
Failed to load latest commit information.
.idea Grrrr, stupid project files. Oct 3, 2012
repo/local I guess I updated the jars that I need in the local repo; it's been a… Jul 21, 2013
zombunity_http Working on swapping out webbit for Ring Jul 30, 2013
zombunity_server Tightened up daemon name matching Jul 28, 2013
zombunity_web No idea what I was doing here. Jul 21, 2013
.gitignore Checking in some IDEA project files that are annoying me when I do a … Oct 3, 2012
README.md Added a note about Webbit not serving all the ClojureScript JS on Win… Jul 21, 2013
copy_libs.bat Fixed json reference in db.clj; got the dispatch tests working Sep 8, 2012
copy_libs.ps1 Created a batch file to copy jar files from the .m2 repo directory to… Sep 8, 2012
copy_web_to_jetty.bat Created a script to copy the web resources to the local Jetty dir for… Jul 21, 2013
db_tests.bat
load_data
load_db.bat Removed custom URI; moved HTML resources to http module; replaced lib… Aug 19, 2012
project.clj Updating to Clojure 1.5 Jul 30, 2013
start FINALLY got the clojure REPL working correctly; updated startup scripts Aug 22, 2012
start_db FINALLY got the clojure REPL working correctly; updated startup scripts Aug 22, 2012
start_db.bat
start_db_manager Created script to start the HSQLDB GUI Jul 23, 2013
start_mud_repl added start_sql_tool script; cleanup of load_data and start_mud_repl … Aug 23, 2012
start_sql_tool added start_sql_tool script; cleanup of load_data and start_mud_repl … Aug 23, 2012

README.md

zombunity-mud

Zombunity MUD

An event-driven web MUD framework consisting of a MUD server, http server and web client.

Scroll to the bottom for a text version of "Getting Started"

YouTube Project Updates (Newest to Oldest):

[GUI Improvements] (http://youtu.be/IHk-2XaKb6A)
[Milestone Reached!] (http://www.youtube.com/watch?v=1IsLhGv5zyM)
[Live DB Unit Tests & Deployment Scripts] (http://www.youtube.com/watch?v=Xb-_RwmZaZc)

YouTube Code Tutorials (Newest to Oldest):

[Debug JavaScript on Jetty Instead of Webbit] (http://www.youtube.com/watch?v=cyv2vzhJQEo&feature=youtu.be)
[Daemon Filtering] (http://www.youtube.com/watch?v=dtMhSVFqHCo&feature=youtu.be)
[Data Interface & Custom Data Test Data Providers] (http://www.youtube.com/watch?v=4wQIEikNlbs)
[Bash Deployment Scripts for Linux] (http://youtu.be/UXCHh9uM14s)
[Getting Started on Heroku] (http://www.youtube.com/watch?v=44YNnFkVeJA)
[Getting Started] (http://www.youtube.com/watch?v=UNd3UT4OShs&feature=youtu.be)
[Login Handling] (http://www.youtube.com/watch?v=gEbyLqxB1C0&feature=youtu.be "Login Handling")
[JDBC Gotchas] (http://www.youtube.com/watch?v=bbScWWj_sPU "JDBC Gotchas")
[Registering Daemons] (http://www.youtube.com/watch?v=HzMQ8c3PWiE "Registering Daemons")
[Basic Framework] (http://www.youtube.com/watch?v=sKdL5onIiWQ "Basic Framework")
[WebSocket Tutorial] (http://www.youtube.com/watch?v=Jl69WXhiX2w "WebSocket Tutorial")
[Compiling ClojureScript] (http://www.youtube.com/watch?v=_25R3MMB_H8 "Compiling ClojureScript")

Web Client:

A ClojureScript web page that uses an event dispatch model to communicate between namespaces in place of a traditional MVC model.

Uses Google Closure WebSocket to communicate with an HTTP server.

HTTP Server:

A Webbit server that does three things:

- registers client connections with an ID
- places text from the client into the MUD server message queue with it's ID
- polls the client message queue for messages from the server and sends them to the appropriate client.

MUD Server:

A event dispatch system that does three things:

- polls the message queue for messages from clients
- writes client messages to the message queue for the HTTP server to relay
- dispatches events to daemons to process into more events

Walkthrough:

- Client types "attack bear"
- web dispatch creates :input event
- websocket namespace sends :text event with text ("attack bear") as JSON to HTTP server
- HTTP server adds connection ID of client to JSON and stores in MUD server message queue
- MUD server polls message queue and removes messages
- MUD server converts the JSON to a Clojure map
- MUD server dispatches on event type (:text) to appropriate daemon
- Daemon processes event, generates more events, sends them to dispatch
- MUD server continues to dispatch out events
- Client message events (:client) are put in the client message queue for the HTTP server
- HTTP server polls the client message queue
- HTTP server looks up client connection by connection ID in message
- HTTP server sends message to client via WebSocket connection.
- web dispatch sends :message event
- web gui namespace displays message / updates gui

Getting Started:

GNU/Linux

This has been simplified down to a set of BASH scripts with a single script to kick everything off.

All scripts assume they are run from you zombunity dev directory (i.e. where your project.clj file is)

First Run

  1. Clone the git repo

    git clone https://github.com/cwmaguire/zombunity-mud

  2. ./start

    runs lein deps
    Starts the HSQLDB
    loads it with data
    builds ClojureScript
    runs HTTP server
    runs a REPL for running the MUD server

  3. Run the MUD server in the resulting REPL

(ns zombunity.dispatch)
(register-daemons)
(start-processing-messages)

Subsequent Runs

Only perform the necessary steps: e.g. if the database is running and has data, it doesn't need to be run again. You can kill the database with:

ps -A | grep java
kill -9 [process ID from previous step]

To remove all the database files and start fresh:

rm -r zombunity.*

If the database goes down, the HTTP and MUD servers should be restarted.

  1. Load dependencies with

    lein deps

  2. Start the database

    ./start_db

  3. Load the database with data

    ./load_data

  4. Build the ClojureScript

    lein run -m zombunity.build/build

  5. Run the HTTP server

    lein run

  6. Run the MUD server

    ./start_mud_repl

    (ns zombunity.dispatch)
    (register-daemons)
    (start-processing-messages)

  7. Open the web page:

    Open a web browser

    Tested with Chrome, should work with Firefox, probably won't work with IE or Opera

    Browse to the zombunity.html file

    e.g. http://localhost/zombunity.html

  8. Click "Connect"

Windows

Arg!

Webbit won't load all of the ClojureScript JavaScript under Windows, so the page won't load properly.

You can test out the client side code by itself (e.g. to debug menus and such) by running the client-side code under Jetty; see http://www.youtube.com/watch?v=cyv2vzhJQEo&feature=youtu.be

This is slowly evolving to require less and less steps

  1. Clone the git repo

    git clone https://github.com/cwmaguire/zombunity-mud

  2. Run lein deps

  3. Start the HSQLDB server

    start_db.bat

  4. Run the setup SQL with SqlTool

    load_db.bat

  5. Run the http server with "lein run"

    open a command prompt to the project dir and run "lein run"

  6. Build the JavaScript

    open a command prompt to the project dir and run "lein run -m zombunity.build/build"

    Currently I'm having to manually massage the Google Closure deps: - add a dependency line to goog/deps.js for useragent/jscript:

    goog.addDependency("useragent/jscript.js", ['goog.userAgent.jscript'], ['goog.string']);

     - add "goog.userAgent.jscript" to the list of dependencies for goog.string.StringBuffer
    

    goog.addDependency("string/stringbuffer.js", ['goog.string.StringBuffer'], ['goog.userAgent.jscript']);

  7. Copy libs from local repo to project lib folder

    copy_libs.bat

  8. Run a REPL for the MUD server

    Assuming %SERV_PATH% is the path to your zombunity_server directory (e.g. c:\dev\zombunity\zombunity_server)

    java -cp %SERV_PATH%\lib\clojure-1.4.0.jar;%SERV_PATH%\lib\*;%SERV_PATH%\src; clojure.main -i %SERV_PATH%\src\zombunity\dispatch.clj -r

    This will load up the dispatch script (-i) but keep the REPL open (-r)

    Run the main function:

    (main)

  9. Open the web page:

    Open a web browser

    Tested with Chrome, should work with Firefox, probably won't work with IE or Opera

    Browse to the zombunity.html file

    e.g. http://localhost/zombunity.html

  10. Click "Connect"