Exemple #1
0
class TWebServer(http.server.HTTPServer):
    def __init__(self, aServerAddress, aHttpHandler, aWebSocket):        
        self.mSocketInx  = 0
        self.mServerAddr = aServerAddress
        self.mWebAddr    = (aServerAddress[0], int(aWebSocket))
        self.mWebSocket  = TWebSocket(self.mWebAddr)
        self.mWebSocket.start()
        self.mRunning    = True
        self.mBluetooth  = TBluetooth()
        self.mTracer     = TTracer()
        
        # start the user services
        # aAgent           = TEezzAgent()
        # aAgent.startServices()
        super().__init__(aServerAddress, aHttpHandler)
        self.mTracer.write(3, 'TWebServer', aMessage = 'listening to:{}:{}'.format(self.mServerAddr, self.mWebAddr))
        
    # ---------------------------------    
    def serve_forever(self):
        while self.mRunning:
            try:
                self.handle_request()
            except KeyboardInterrupt:
                self.shutdown()
                break
   
    # ---------------------------------    
    def shutdown(self):
        self.mTracer.write(1, 'shutdown')
        self.mWebSocket.shutdown()
        self.mRunning = False
Exemple #2
0
 def __init__(self, aServerAddress, aHttpHandler, aWebSocket):        
     self.mSocketInx  = 0
     self.mServerAddr = aServerAddress
     self.mWebAddr    = (aServerAddress[0], int(aWebSocket))
     self.mWebSocket  = TWebSocket(self.mWebAddr)
     self.mWebSocket.start()
     self.mRunning    = True
     self.mBluetooth  = TBluetooth()
     self.mTracer     = TTracer()
     
     # start the user services
     # aAgent           = TEezzAgent()
     # aAgent.startServices()
     super().__init__(aServerAddress, aHttpHandler)
     self.mTracer.write(3, 'TWebServer', aMessage = 'listening to:{}:{}'.format(self.mServerAddr, self.mWebAddr))