def run_gevent_server(host="127.0.0.1", port=9001):
    from gevent import monkey; monkey.patch_all()
    from ws4py.server.geventserver import WebSocketServer
    from ws4py.websocket import EchoWebSocket
    
    server = WebSocketServer((host, port), websocket_class=EchoWebSocket)
    server.serve_forever()
def run_gevent_server(host="127.0.0.1", port=9001):
    from gevent import monkey; monkey.patch_all()
    from ws4py.server.geventserver import WebSocketServer
    from ws4py.websocket import EchoWebSocket
    
    server = WebSocketServer((host, port), websocket_class=EchoWebSocket)
    logger = logging.getLogger('autobahn_testsuite')
    logger.warning("Serving gevent server on %s:%s" % (host, port))
    server.serve_forever()
Beispiel #3
0
def run_gevent_server(host="127.0.0.1", port=9001):
    from gevent import monkey
    monkey.patch_all()
    from ws4py.server.geventserver import WebSocketServer
    from ws4py.websocket import EchoWebSocket

    server = WebSocketServer((host, port), websocket_class=EchoWebSocket)
    logger = logging.getLogger('autobahn_testsuite')
    logger.warning("Serving gevent server on %s:%s" % (host, port))
    server.serve_forever()
Beispiel #4
0
def run_standalone_ws4py():
    from ws4py.server.geventserver import WebSocketServer

    def _fake_start_response(self, *args, **kwargs):
        return None

    def ws4py_app_wrapper(websocket, environ):
        environ['wsgi.websocket'] = websocket
        websocket.sock = websocket.socket
        return app(environ, _fake_start_response)

    server = WebSocketServer((HOST, PORT),
        application=ws4py_app_wrapper)
    server.serve_forever()
Beispiel #5
0
def server(websocket_class, address=('0.0.0.0', 9001)):
    print('Starting websocket server...')
    server = WebSocketServer(address, websocket_class=websocket_class)
    server.serve_forever()
Beispiel #6
0
    def __init__(self, hub):
        self.hub = hub

        self.add_service(
            WebSocketServer((self.hub.bind_interface, self.port), self.handle))
Beispiel #7
0
 def __init__(self, host, port):
     WebSocketServer.__init__(self, (host, port))
     self.application = self
     self.ws = WebSocketUpgradeMiddleware(app=self.wsHandler,websocket_class=Lab126WebSocket)
Beispiel #8
0

if __name__ == '__main__':
    reflector = NullMQReflector()

    def websocket_handler(websocket, environ):
        if environ.get('PATH_INFO') == '/reflector':
            StompHandler(websocket, reflector).serve()
        else:
            websocket.close()

    def http_handler(environ, start_response):
        if '/dist' in environ['PATH_INFO'] and environ['PATH_INFO'].split(
                '/')[1] == 'dist':
            filename = '../..%s' % environ['PATH_INFO']
        else:
            filename = environ['PATH_INFO'].split('/')[-1] or 'index.html'
        if os.path.exists(filename):
            start_response(
                '200 OK',
                [('Content-type', mimetypes.guess_type(filename)[0])])
            return [open(filename).read()]
        else:
            start_response('404 Not found', [('Content-type', 'text/plain')])
            return ["Not found"]

    server = WebSocketServer(('127.0.0.1', 9000),
                             websocket_handler,
                             fallback_app=http_handler)
    print "Starting NullMQ reflector on 9000..."
    server.serve_forever()
Beispiel #9
0
 def run(self):
     server = WebSocketServer(('127.0.0.1', 8001), websocket_class=PrintWebSocket)
     server.serve_forever()
Beispiel #10
0
from gevent import monkey
monkey.patch_all()
import gevent

from ws4py.server.geventserver import WebSocketServer
from ws4py.websocket import EchoWebSocket

server = WebSocketServer(('127.0.0.1', 9001), websocket_class=EchoWebSocket)
server.serve_forever()
Beispiel #11
0
from ws4py.server.geventserver import WebSocketServer
from ws4py.websocket import WebSocket
import gevent
import time


class EchoServer(WebSocket):
    def received_message(self, message):
        self.send(message.data, message.is_binary)


if __name__ == '__main__':
    server = WebSocketServer(('', 8000), websocket_class=EchoServer)
    print "listening on port 8000"
    server.serve_forever()
Beispiel #12
0
from gevent import monkey; monkey.patch_all()
import gevent

from ws4py.server.geventserver import WebSocketServer
from ws4py.websocket import EchoWebSocket

server = WebSocketServer(('127.0.0.1', 9001), websocket_class=EchoWebSocket)
server.serve_forever()
Beispiel #13
0
    def send(self, frame):
        type = frame.headers.get('socket')
        if type in ['req', 'rep']:
            reply_to = frame.headers.get('reply-to')
            if type == 'req':
                uid = '%s-%s' % (frame.conn_id, reply_to)
            else:
                uid = reply_to
            conn = self.connection_by_uid[uid]
            conn.socket.send(frame.body)
            if type == 'req':

                def wait_for_reply():
                    conn.send(conn.socket.recv())

                conn.listener = gevent.spawn(wait_for_reply)
        elif type in ['pub', 'push', 'dealer']:
            conns = list(self.connection_by_destination[frame.destination])
            if len(conns):
                conns[0].socket.send(frame.body)


if __name__ == '__main__':

    def websocket_handler(websocket, environ):
        StompHandler(websocket, ZeroMQBridge()).serve()

    server = WebSocketServer(('0.0.0.0', 9000), websocket_handler)
    print "Starting NullMQ-ZeroMQ bridge on 9000"
    server.serve_forever()
Beispiel #14
0
 def run(self):
     server = WebSocketServer(('127.0.0.1', 8001),
                              websocket_class=PrintWebSocket)
     server.serve_forever()
Beispiel #15
0
def listen(port, path=None):
    server = WebSocketServer(('', port), handler(path))
    server.serve_forever()
Beispiel #16
0
def listen(port, path=None):
    server = WebSocketServer(('', port), handler(path))
    server.serve_forever()