خرید بک لینک

Vote count: 0

https://github.com/abourget/gevent-socketio/blob/master/examples/simple_chat/chat.py

 def __call__(self, environ, start_response):
    path = environ['PATH_INFO'].strip('/')

    if not path:
        start_response('200 OK', [('Content-Type', 'text/html')])
        retu ['<h1>Welcome. '
            'Try the <a href="/chat.html">chat</a> example.</h1>']

    if path.startswith('static/') or path == 'chat.html':
        try:
            data = open(path).read()
        except Exception:
            retu not_found(start_response)

        if path.endswith(".js"):
            content_type = "text/javascript"
        elif path.endswith(".css"):
            content_type = "text/css"
        elif path.endswith(".swf"):
            content_type = "application/x-shockwave-flash"
        else:
            content_type = "text/html"

        start_response('200 OK', [('Content-Type', content_type)])
        retu [data]

    if path.startswith("socket.io"):
        socketio_manage(environ, {'': ChatNamespace}, self.request)
    else:
        retu not_found(start_response)


def not_found(start_response):
  start_response('404 Not Found', [])
     retu ['<h1>Not Found</h1>']


 if __name__ == '__main__':
   print 'Listening on port 8080 and on port 843 (flash policy server)'
   SocketIOServer(('0.0.0.0', 8080), Application(),
    resource="socket.io", policy_server=True,
     policy_listener=('0.0.0.0', 10843)).serve_forever()

I am trying to follow and understand other implementation of message systems. Currently I have done my own implementation of the basic serverside function ( coect,message, discoect methods ect... ) however I am yet to touch the client side of it - what I'm not understanding is like an example one on github below: I'm a bit clueless about all of this to be honest.. and I'm looking to hook mine up via my local server used for my django project ( python manage.py runserver).. I need to test my current methods with the server to see if it detects when a user has coected/discoected but I can't because I'm not truly understanding the below..

asked 35 secs ago

برچسب: نویسنده: استخدام کار تاريخ: پنجشنبه 2 ارديبهشت 1395 ساعت: 5:16

صفحه بندی