Example #1
0
def ws_handler(conn):
    with WebSocketServer(conn, 'a') as ws:

        while True:
            if ws.state == 1:
                data = get_details()
                ws.send(bytes(json.dumps(data), encoding='utf8'))
            elif ws.state == -1:
                break
            time.sleep(1)
Example #2
0
	def onStop( self ):
		WebHTTPServer.stopServer()
		WebSocketServer.stopServer()
Example #3
0
	def onStart( self ):
		WebHTTPServer.startServer()
		WebSocketServer.startServer( self.onSocketData )
Example #4
0
        try:
            from platformcode.controllers.html import html
            self.controller = html(self)
            platformtools.controllers[self.ID] = self.controller
            self.server.fnc_info()
        except:
            logger.error(traceback.format_exc())

    def handleClose(self):
        self.controller = None
        del platformtools.controllers[self.ID]
        self.server.fnc_info()


port = int(config.get_setting("websocket.port"))
server = WebSocketServer.SimpleWebSocketServer("", port, HandleWebSocket)


def start(fnc_info):
    server.fnc_info = fnc_info
    Thread(target=server.serveforever).start()


def stop():
    server.close()


def show_error_message(err_info):
    from core import scrapertools
    patron = 'File "' + os.path.join(config.get_runtime_path(), "channels",
                                     "").replace("\\", "\\\\") + '([^.]+)\.py"'
Example #5
0
            self.ID = "%032x" % (random.getrandbits(128))
            from platformcode.controllers.html import html
            self.controller = html(self, self.ID)
            self.server.fnc_info()
        except:
            logger.error(traceback.format_exc())
            self.close()

    def handleClose(self):
        self.controller.__del__()
        del self.controller
        self.server.fnc_info()


port = config.get_setting("websocket.port")
server = WebSocketServer.SimpleWebSocketServer("", int(port), HandleWebSocket)


def start(fnc_info):
    server.fnc_info = fnc_info
    Thread(target=server.serveforever).start()


def stop():
    server.close()


def run(controller, path):
    try:
        controller.run(path)
    except:
Example #6
0
      elif str(self.data).startswith("!"):
        sys.argv[str(self)]["Data"]=str(self.data).replace("!","")
      

   def handleConnected(self):
      sys.argv[str(self)]={"Socket": self, "Request":"", "Data":"","Host":""}
      self.sendMessage('{"Action": "Connect", "Version": "pelisalacarta '+version+'", "Date":"'+fecha+'"}')
      global MostrarInfo
      MostrarInfo()

   def handleClose(self):
    if str(self) in sys.argv:
      del sys.argv[str(self)]
      global MostrarInfo
      MostrarInfo()



WebsocketPort=int(config.get_setting("websocket.port"))
server = WebSocketServer.SimpleWebSocketServer("",WebsocketPort,HandleWebSocket)

def start(Request, Info):
    global ProcessRequest
    global MostrarInfo
    ProcessRequest=Request
    MostrarInfo = Info
    Thread(target=server.serveforever).start()
 
def stop():
    server.close()
Example #7
0
 def onStop(self):
     WebHTTPServer.stopServer()
     WebSocketServer.stopServer()
Example #8
0
 def onStart(self):
     WebHTTPServer.startServer()
     WebSocketServer.startServer(self.onSocketData)
import WebSocketServer

WebSocketServer.WebSocketServer()