本文整理汇总了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
示例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)
示例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
示例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()
示例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()
示例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()
示例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))
示例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()
示例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()
示例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()
示例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!")
示例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")
示例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()
示例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")
示例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!")