当前位置: 首页>>代码示例>>Python>>正文


Python SimpleWebSocketServer.SimpleWebSocketServer类代码示例

本文整理汇总了Python中SimpleWebSocketServer.SimpleWebSocketServer的典型用法代码示例。如果您正苦于以下问题:Python SimpleWebSocketServer类的具体用法?Python SimpleWebSocketServer怎么用?Python SimpleWebSocketServer使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了SimpleWebSocketServer类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: LogRecordSocketReceiver

class LogRecordSocketReceiver(SocketServer.ThreadingTCPServer):
    allow_reuse_address = 1

    def __init__(self, host='localhost',
                 port=logging.handlers.DEFAULT_TCP_LOGGING_PORT,
                 handler=LogRecordStreamHandler):

        SocketServer.ThreadingTCPServer.__init__(self, (host, port), handler)
        self.abort = 0
        self.timeout = 1
        self.logname = None
        self.requstHandle = None
        self.wsserver = SimpleWebSocketServer('', 8081, WebSocket)

    def finish_request(self, request, client_address):
        LogRecordStreamHandler(request, client_address, self, self.wsserver)

    def cleanup(self):
        self.wsserver.close()

    def serve_until_stopped(self):
        import select
        abort = 0
        while not abort:
            self.wsserver.servconnman()

            rd, wr, ex = select.select([self.socket.fileno()], [], [], self.timeout)
            if rd:
                self.handle_request()
            abort = self.abort
开发者ID:TinyOS-Camp,项目名称:DDEA-DEV,代码行数:30,代码来源:main.py

示例2: WSServerThread

class WSServerThread( threading.Thread ):
	"""
	La clase cliente socket que se levanta como un hilo de proceso 
	independiente.
	"""
	def __init__ ( self, sktServer):
		"""
		Inicializacion de la clase
		"""
		self.wshandlerclass = ''
		self.sktServer = sktServer
		self.wSktServer = SimpleWebSocketServer('', 9000, SimpleEcho)
		threading.Thread.__init__ ( self )


	def setWSHandlerClass(self, instance):
		self.wshandlerclass = instance


	def run ( self ):
		"""
		Una vez inicializada la clase esta es ejecutada en este metodo
		"""
		self.wSktServer.setInvoker(self)
		self.sktServer.attach(self)
		self.wSktServer.serveforever()

	def sendMessage(self, data):
		if self.wshandlerclass != '':
			self.wshandlerclass.send_bytes(data)
开发者ID:ppvasqueze,项目名称:bolas_sag,代码行数:30,代码来源:proxysws.py

示例3: __init__

	def __init__(self, host, port, websocketclass, certfile, keyfile, version = ssl.PROTOCOL_TLSv1):

		SimpleWebSocketServer.__init__(self, host, port, websocketclass)

		self.cerfile = certfile
		self.keyfile = keyfile
		self.version = version
开发者ID:Mondego,项目名称:pyreco,代码行数:7,代码来源:allPythonContent.py

示例4: WebSocketServer

class WebSocketServer(threading.Thread):
    def __init__(self):
        threading.Thread.__init__(self)
        self.server = SimpleWebSocketServer("", WEB_SOCKET_PORT_NUMBER, WebSocketHandler)


    def run(self):
        log.info("Starting WebSocketServer on port %d" % WEB_SOCKET_PORT_NUMBER)
        self.server.serveforever()
开发者ID:hex007,项目名称:pifm_server,代码行数:9,代码来源:main.py

示例5: runServer

def runServer():
	server = SimpleWebSocketServer("", 8532, VaticServer)

	def close_sig_handler(signal, frame):
		server.close()
		sys.exit()

	signal.signal(signal.SIGINT, close_sig_handler)

	server.serveforever()
开发者ID:vovakkk,项目名称:vatic,代码行数:10,代码来源:wsserver.py

示例6: serve

def serve():

    '''
    class InputServer(WebSocket):
        tilt = 0
        def __init__(self, *args, **kwargs):
            super(InputServer, self).__init__(*args, **kwargs)
            self.runloop = None

        def handleConnected(self):
            print(self.address, 'connected')
            self.runloop = input.KinectLoop(self)
            self.runloop.start()

        def handleClose(self):
            self.runloop.kill()
            print(self.address, 'closed')

        def handleMessage(self):
            self.tilt = int(float(self.data))
    '''
    class InputServer(WebSocket):

        def __init__(self, *args, **kwargs):
            super(InputServer, self).__init__(*args, **kwargs)
            self.kinect = None
            self.oid = None

        def handleConnected(self):
            print self.address, 'connected'
            self.kinect = KinectFactory.create_kinect()
            self.oid = uuid.uuid1()
            self.kinect.add_observer(self.oid, self.send_depth)

        def handleClose(self):
            self.kinect.remove_observer(self.oid)
            print self.address, 'closed'

        def handleMessage(self):
            degs = int(float(self.data))
            self.kinect.set_tilt(degs)

        def send_depth(self, depth):
            self.sendMessage(depth)

    def close_sig_handler(signum, frame):
        server.close()
        KinectFactory.kill()
        sys.exit()

    signal.signal(signal.SIGINT, close_sig_handler)
    server = SimpleWebSocketServer('0.0.0.0', 1337, InputServer)
    server.serveforever()
开发者ID:regar007,项目名称:Kimotion,代码行数:53,代码来源:server.py

示例7: NetworkServerSocket

class NetworkServerSocket(Thread):
    def __init__(self, lettre):
        Thread.__init__(self)
        self.server = SimpleWebSocketServer("", portWebSocket, ClientWebSocket)
        print "WEBSOCKET listenning ..."

    def run(self):
        self.server.serveforever()

    def broadcastAll(self, jsonMessage):
        for c in clients:
            c.sendMessage(json.dumps(jsonMessage, ensure_ascii=False))
开发者ID:Blackout76,项目名称:Cab-Rel,代码行数:12,代码来源:NetworkWebSocket.py

示例8: __init__

 def __init__(self, system):
     from . import skeleton
     SimpleWebSocketServer.__init__(self, '', 9121, _DlalWebSocket)
     self.root = _Root(
         weakref.proxy(system),
         skeleton,
         lambda: FREE,
     )
     self.store = {}
     self.thread = threading.Thread(target=_serve, args=(weakref.ref(self),))
     self.thread.daemon = True
     self.thread.start()
开发者ID:dansgithubuser,项目名称:dlal,代码行数:12,代码来源:_websocket.py

示例9: main

def main():
    print("Starting WebSocket ...")
    server = SimpleWebSocketServer('localhost', 8000, DataServer)
    print("WebSocket Ready!")

    def close_sig_handler(signal, frame):
        print("\nClosing WebSocket ...")
        server.close()
        print("Bye!")
        sys.exit()

    signal.signal(signal.SIGINT, close_sig_handler)
    server.serveforever()
开发者ID:lumbric,项目名称:angezeige,代码行数:13,代码来源:web_socket.py

示例10: Server

class Server(Thread):
    def run(self):
        """Starts the thread for the Web Socket Server"""
        host = ""
        port = 8008
        self.server = SimpleWebSocketServer(host, port, Logger)

        print("serving")
        self.server.serveforever()

    def close_sig_handler(self, signal, frame):
        """Function called upon Ctrl+C that kills the program"""
        print("closing")
        self.server.close()
开发者ID:LoganGirard,项目名称:EyeTribe,代码行数:14,代码来源:EyeReader.py

示例11: FSWebSocketServer

class FSWebSocketServer(threading.Thread):

    def __init__(self):
        threading.Thread.__init__(self)
        self.port = 8010
        self._logger = logging.getLogger(__name__)

    def run(self):
        #try:
            self._logger.info("Websocket Server started on port %s" % self.port)
            self.wsd = SimpleWebSocketServer('', self.port, FSWebSocket)
            self.wsd.serveforever()
        #except:
        #    self._logger.error("WebSocket Crash!")
开发者ID:bootinge,项目名称:FabScanPi-Server,代码行数:14,代码来源:__init__.py

示例12: FSWebSocketServer

class FSWebSocketServer(FSWebSocketServerInterface):

    def __init__(self):
        super(FSWebSocketServerInterface, self).__init__(group=None)
        self.port = 8010
        self._logger = logging.getLogger(__name__)

    def run(self):
            self._logger.info("Websocket Server started on port %s" % self.port)
            try:
                self.wsd = SimpleWebSocketServer('', self.port, FSWebSocket)
                self.wsd.serveforever()
            except:
                self._logger.error("Websocket not started")
开发者ID:jenshackel,项目名称:FabScanPi-Server,代码行数:14,代码来源:__init__.py

示例13: socketServerThread

class socketServerThread(threading.Thread):
	def __init__(self, host, port, socketQueue):
		threading.Thread.__init__(self)
		self.cls = socketServer
		self.socketQueue = socketQueue
		self.server = SimpleWebSocketServer(host, port, self.socketQueue, self.cls)
	
	def run(self):
		print "starting Server"
		self.server.serveforever()
		
	def exit(self):
		print "stoping Server"
		self.server.close()
开发者ID:mattfullerton,项目名称:Zoidberg,代码行数:14,代码来源:socketServer.py

示例14: run

 def run(self):
         self._logger.info("Websocket Server started on port %s" % self.port)
         try:
             self.wsd = SimpleWebSocketServer('', self.port, FSWebSocket)
             self.wsd.serveforever()
         except:
             self._logger.error("Websocket not started")
开发者ID:jenshackel,项目名称:FabScanPi-Server,代码行数:7,代码来源:__init__.py

示例15: run

 def run(self):
     #try:
         self._logger.info("Websocket Server started on port %s" % self.port)
         self.wsd = SimpleWebSocketServer('', self.port, FSWebSocket)
         self.wsd.serveforever()
     #except:
     #    self._logger.error("WebSocket Crash!")
开发者ID:bootinge,项目名称:FabScanPi-Server,代码行数:7,代码来源:__init__.py


注:本文中的SimpleWebSocketServer.SimpleWebSocketServer类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。