aboutsummaryrefslogtreecommitdiffstats
path: root/fg21sim/webui/app.py
diff options
context:
space:
mode:
authorAaron LI <aaronly.me@outlook.com>2016-11-15 20:50:18 +0800
committerAaron LI <aaronly.me@outlook.com>2016-11-15 20:50:18 +0800
commit81d8455ce56e6c94f3f97089255ed155489764e9 (patch)
tree0b42df3e3f1aaefc897ddeaa597db192bea6e3db /fg21sim/webui/app.py
parentc23498126941c94fd1bbf521995684b7e02bf1d5 (diff)
downloadfg21sim-81d8455ce56e6c94f3f97089255ed155489764e9.tar.bz2
webui: Save connected WebSocket clients and allow broadcast
Diffstat (limited to 'fg21sim/webui/app.py')
-rw-r--r--fg21sim/webui/app.py20
1 files changed, 19 insertions, 1 deletions
diff --git a/fg21sim/webui/app.py b/fg21sim/webui/app.py
index 3793fda..199e2d6 100644
--- a/fg21sim/webui/app.py
+++ b/fg21sim/webui/app.py
@@ -22,14 +22,32 @@ from ..configs import ConfigManager
class Application(tornado.web.Application):
- configmanager = ConfigManager()
+ """
+ Application of the "fg21sim" Web UI.
+
+ Attributes
+ ----------
+ configmanager : `~fg21sim.configs.ConfigManager`
+ A ``ConfigManager`` instance, which saves the current configurations
+ status. The configuration operations (e.g., "set", "get", "load")
+ are performed on this instance, which is also passed to the
+ foregrounds simulation programs.
+ ws_clients : set
+ Current connected clients through WebSocket.
+ When a new WebSocket connection established, it is added to this
+ list, which is also removed from this list when the connection lost.
+ """
def __init__(self, **kwargs):
+ self.configmanager = ConfigManager()
+ self.ws_clients = set()
+ # URL handlers
handlers = [
url(r"/", IndexHandler, name="index"),
url(r"/login", LoginHandler, name="login"),
url(r"/ws", FG21simWSHandler),
]
+ # Application settings
settings = {
# The static files will be served from the default "/static/" URI.
# Recommend to use `{{ static_url(filepath) }}` in the templates.