From 2bbdd6cf3a0ea429583a9e4b840e68c238e08a46 Mon Sep 17 00:00:00 2001 From: RaNaN Date: Sat, 22 Sep 2012 16:21:17 +0200 Subject: web socket api handler --- module/remote/wsbackend/EventHandler.py | 41 +++++++++++++++++++++++++++++++++ 1 file changed, 41 insertions(+) create mode 100644 module/remote/wsbackend/EventHandler.py (limited to 'module/remote/wsbackend/EventHandler.py') diff --git a/module/remote/wsbackend/EventHandler.py b/module/remote/wsbackend/EventHandler.py new file mode 100644 index 000000000..deab25a6c --- /dev/null +++ b/module/remote/wsbackend/EventHandler.py @@ -0,0 +1,41 @@ +#!/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.msgutil import receive_message, send_message + +class EventHandler: + + def __init__(self, api): + self.api = api + + 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