示例#1
0
def main():
    log.startLogging(sys.stdout)
    root = File(".")
    site = WebSocketSite(root)
    site.addHandler("/ws/echo", ChattyHandler)
    reactor.listenTCP(8080, site)
    reactor.run()
示例#2
0
文件: server.py 项目: jMyles/WHAT
def main():
    log.startLogging(sys.stdout)
    root = File("/home/slashroot/workspace/slashrootcafe/push/websocket_server")
    site = WebSocketSite(root)
    site.addHandler("ws/echo", Echohandler)
    reactor.listenTCP(7000, site)
    reactor.run()
示例#3
0
def main():
    log.startLogging(sys.stdout)
    root = File(".")
    site = WebSocketSite(root)
    site.addHandler("/ws/echo", ChattyHandler)
    reactor.listenTCP(8080, site)
    reactor.run()
示例#4
0
def main():
    from twisted.internet import reactor
    log.startLogging(sys.stdout)
    root = static.File('.')
    site = WebSocketSite(root)
    site.addHandler("/ws/chat", ChatHandler)
    reactor.listenTCP(9876, site)
    reactor.run()
示例#5
0
def main():

    log.startLogging(sys.stdout)
    root = File(".")
    site = WebSocketSite(root)
    site.addHandler("/ws/echo", echo_factory)
    reactor.listenTCP(8080, site)

    #listen to stomp
    reactor.connectTCP('localhost', 61613, StompClientFactory())
    reactor.run()
示例#6
0
            self.connections.remove(p)
            self.post_message('chat server', '%s disconnected' % p.host)

    
    def post_message(self, from_addr, message):
        for p in self.connections:
            p.sendMessage('%s:%s' % (from_addr, message))

if __name__ == '__main__':
    log.startLogging(sys.stdout)
    root = File(".")
    
    logging.basicConfig(level=logging.DEBUG)
    factory = ChatFactory()

    site = WebSocketSite(root)
    site.addHandler("/ws/echo", ChatWebsocketProtocol)
    
    reactor.listenTCP(8007, factory)
    reactor.run()


    
#    from twisted.internet.ssl import PrivateCertificate
#    from twisted.protocols.tls import TLSMemoryBIOFactory
#    certificate = PrivateCertificate.loadPEM(certPEMData)
#    contextFactory = certificate.options()
#    tlsFactory = TLSMemoryBIOFactory(contextFactory, False, factory)    
#    reactor.listenTCP(8008, tlsFactory)
    
    reactor.run()
示例#7
0
from twisted.internet import reactor
from twisted.web.websocket import WebSocketHandler, WebSocketSite
from twisted.web.static import File


class Echohandler(WebSocketHandler):
    def frameReceived(self, frame):
        self.transport.write(frame)


if __name__ == '__main__':
    root = File('.')
    site = WebSocketSite(root)
    site.addHandler('/echo', Echohandler)
    reactor.listenTCP(8080, site)
    reactor.run()
示例#8
0
from twisted.internet import reactor
from twisted.web.websocket import WebSocketHandler, WebSocketSite
from twisted.web.static import File


class Echohandler(WebSocketHandler):

    def frameReceived(self, frame):
        self.transport.write(frame)


if __name__ == "__main__":
    root = File(".")
    site = WebSocketSite(root)
    site.addHandler("/echo", Echohandler)
    reactor.listenTCP(8080, site)
    reactor.run()