Implement first event for javascript
This commit is contained in:
parent
885df2f4fe
commit
dc10240c2d
|
@ -4,6 +4,7 @@ from bottle.ext.websocket import websocket
|
|||
from os.path import join as pathjoin
|
||||
from statemachine import InitState, RegisteringState, IdleState, SchelltState, AcceptingState, CallTerminatingState, ForgottenState, BusyBeepingState, CallRunningState, WecktState, ConnectingState, DialingState
|
||||
import threading
|
||||
import json
|
||||
|
||||
class WebInitState(InitState):
|
||||
def __init__(self, web):
|
||||
|
@ -66,9 +67,8 @@ class WebDialingState(DialingState):
|
|||
super().__init__(web.controller)
|
||||
|
||||
def on_nummernschalter_input(self, num):
|
||||
print("calling super method")
|
||||
super().on_nummernschalter_input(num)
|
||||
print("local method got num: " + str(num))
|
||||
#self.web.send_event({"event": "num_entered", "data": {"number": int(num)}})
|
||||
|
||||
|
||||
class FeTapWeb():
|
||||
|
@ -86,12 +86,15 @@ class FeTapWeb():
|
|||
return "<h1>Hello world!</h1>"
|
||||
|
||||
def publish_status(self):
|
||||
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"
|
||||
|
||||
def send_event(self, js_event):
|
||||
data = json.dumps(js_event)
|
||||
for ws in self.websockets:
|
||||
ws.send(data)
|
||||
|
||||
def ws_connect(self, ws):
|
||||
self.websockets.append(ws)
|
||||
|
|
Loading…
Reference in a new issue