Add state class hooks
This commit is contained in:
parent
e228c2ac53
commit
885df2f4fe
|
@ -2,12 +2,68 @@ from bottle import route, get, static_file, run
|
|||
from bottle.ext.websocket import GeventWebSocketServer
|
||||
from bottle.ext.websocket import websocket
|
||||
from os.path import join as pathjoin
|
||||
from statemachine import DialingState
|
||||
from statemachine import InitState, RegisteringState, IdleState, SchelltState, AcceptingState, CallTerminatingState, ForgottenState, BusyBeepingState, CallRunningState, WecktState, ConnectingState, DialingState
|
||||
import threading
|
||||
|
||||
class WebInitState(InitState):
|
||||
def __init__(self, web):
|
||||
self.web = web
|
||||
super().__init__(web.controller)
|
||||
|
||||
class WebRegisteringState(RegisteringState):
|
||||
def __init__(self, web):
|
||||
self.web = web
|
||||
super().__init__(web.controller)
|
||||
|
||||
class WebIdleState(IdleState):
|
||||
def __init__(self, web):
|
||||
self.web = web
|
||||
super().__init__(web.controller)
|
||||
|
||||
class WebSchelltState(SchelltState):
|
||||
def __init__(self, web):
|
||||
self.web = web
|
||||
super().__init__(web.controller)
|
||||
|
||||
class WebAcceptingState(AcceptingState):
|
||||
def __init__(self, web):
|
||||
self.web = web
|
||||
super().__init__(web.controller)
|
||||
|
||||
class WebCallTerminatingState(CallTerminatingState):
|
||||
def __init__(self, web):
|
||||
self.web = web
|
||||
super().__init__(web.controller)
|
||||
|
||||
class WebForgottenState(ForgottenState):
|
||||
def __init__(self, web):
|
||||
self.web = web
|
||||
super().__init__(web.controller)
|
||||
|
||||
class WebBusyBeepingState(BusyBeepingState):
|
||||
def __init__(self, web):
|
||||
self.web = web
|
||||
super().__init__(web.controller)
|
||||
|
||||
class WebCallRunningState(CallRunningState):
|
||||
def __init__(self, web):
|
||||
self.web = web
|
||||
super().__init__(web.controller)
|
||||
|
||||
class WebWecktState(WecktState):
|
||||
def __init__(self, web):
|
||||
self.web = web
|
||||
super().__init__(web.controller)
|
||||
|
||||
class WebConnectingState(ConnectingState):
|
||||
def __init__(self, web):
|
||||
self.web = web
|
||||
super().__init__(web.controller)
|
||||
|
||||
class WebDialingState(DialingState):
|
||||
def __init__(self, controller):
|
||||
super().__init__(controller)
|
||||
def __init__(self, web):
|
||||
self.web = web
|
||||
super().__init__(web.controller)
|
||||
|
||||
def on_nummernschalter_input(self, num):
|
||||
print("calling super method")
|
||||
|
@ -30,9 +86,9 @@ class FeTapWeb():
|
|||
return "<h1>Hello world!</h1>"
|
||||
|
||||
def publish_status(self):
|
||||
if isinstance(self.controller.state, DialingState):
|
||||
self.controller.state = WebDialingState(self.controller)
|
||||
print("dialing")
|
||||
print(self.controller.state.__class__.__name__)
|
||||
new_state = eval("Web" + self.controller.state.__class__.__name__)(self)
|
||||
self.controller.state = new_state
|
||||
for ws in self.websockets:
|
||||
ws.send("this is a message triggered from the server")
|
||||
return "ok"
|
||||
|
|
Loading…
Reference in a new issue