From 7007ebe7710d29f26696de16407beced6dbacb6c Mon Sep 17 00:00:00 2001 From: RaNaN Date: Fri, 21 Sep 2012 23:27:12 +0200 Subject: added websocket backend, removed thrift --- module/remote/wsbackend/Dispatcher.py | 53 +++++++++++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 module/remote/wsbackend/Dispatcher.py (limited to 'module/remote/wsbackend/Dispatcher.py') diff --git a/module/remote/wsbackend/Dispatcher.py b/module/remote/wsbackend/Dispatcher.py new file mode 100644 index 000000000..eb1c9a291 --- /dev/null +++ b/module/remote/wsbackend/Dispatcher.py @@ -0,0 +1,53 @@ +#!/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 +############################################################################### + +from mod_pywebsocket import util +from mod_pywebsocket.dispatch import Dispatcher as BaseDispatcher +from mod_pywebsocket.msgutil import receive_message, send_message + +class Dispatcher(BaseDispatcher): + + def __init__(self): + self._logger = util.get_class_logger(self) + + self._handler_suite_map = {} + self._source_warnings = [] + + def addHandler(self, path, handler): + self._handler_suite_map[path] = handler + + + +class ApiHandler: + + def do_extra_handshake(self, req): + pass + + def transfer_data(self, req): + + while True: + try: + line = receive_message(req) + except TypeError: # connection closed + return + + print "Got", line + send_message(req, "You send: %s" % line) + + def passive_closing_handshake(self, req): + print "Closed", req \ No newline at end of file -- cgit v1.2.3