def listenWS(factory, contextFactory=None, backlog=50, interface=''):
 if hasattr(factory, 'reactor'):
  reactor = factory.reactor
 else:
  from twisted.internet import reactor
 if factory.isSecure:
  if (contextFactory is None):
   raise Exception('Secure WebSocket listen requested, but no SSL context factory given')
  listener = reactor.listenSSL(factory.port, factory, contextFactory, backlog, interface)
 else:
  listener = reactor.listenTCP(factory.port, factory, backlog, interface)
 return listener

def listenWS ( factory , contextFactory = None , backlog = 50 , interface = '' ) : if hasattr ( factory , 'reactor' ) : reactor = factory . reactor else : from twisted . internet import reactor if factory . isSecure : if ( contextFactory is None ) : raise Exception ( 'Secure WebSocket listen requested, but no SSL context factory given' ) listener = reactor . listenSSL ( factory . port , factory , contextFactory , backlog , interface ) else : listener = reactor . listenTCP ( factory . port , factory , backlog , interface ) return listener
listen for incoming websocket connections from clients .