diff options
author | RaNaN <Mast3rRaNaN@hotmail.de> | 2012-09-21 23:27:12 +0200 |
---|---|---|
committer | RaNaN <Mast3rRaNaN@hotmail.de> | 2012-09-21 23:27:12 +0200 |
commit | 7007ebe7710d29f26696de16407beced6dbacb6c (patch) | |
tree | c2bebbe1fc243fae6622804f708c6e2c87408ca4 /module/remote/WebSocketBackend.py | |
parent | merge newest changes (diff) | |
download | pyload-7007ebe7710d29f26696de16407beced6dbacb6c.tar.xz |
added websocket backend, removed thrift
Diffstat (limited to 'module/remote/WebSocketBackend.py')
-rw-r--r-- | module/remote/WebSocketBackend.py | 47 |
1 files changed, 47 insertions, 0 deletions
diff --git a/module/remote/WebSocketBackend.py b/module/remote/WebSocketBackend.py new file mode 100644 index 000000000..7af927d8f --- /dev/null +++ b/module/remote/WebSocketBackend.py @@ -0,0 +1,47 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- + +############################################################################### +# Copyright(c) 2008-2012 pyLoad Team +# http://www.pyload.org +# +# This file is part of pyLoad. +# pyLoad is free software: you can redistribute it and/or modify +# it under the terms of the GNU Affero General Public License as +# published by the Free Software Foundation, either version 3 of the +# License, or (at your option) any later version. +# +# Subjected to the terms and conditions in LICENSE +# +# @author: RaNaN +############################################################################### + +import logging + +from module.remote.RemoteManager import BackendBase + +from mod_pywebsocket import util +def get_class_logger(o): + return logging.getLogger('log') + +# Monkey patch for our logger +util.get_class_logger = get_class_logger + +class WebSocketBackend(BackendBase): + def setup(self, host, port): + + + from wsbackend.Server import WebSocketServer, DefaultOptions + from wsbackend.Dispatcher import Dispatcher, ApiHandler + + options = DefaultOptions() + options.server_host = host + options.port = port + options.dispatcher = Dispatcher() + options.dispatcher.addHandler('/api', ApiHandler()) + + self.server = WebSocketServer(options) + + + def serve(self): + self.server.serve_forever() |