How to use SketchΒΆ

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
from jaspion import Jaspion
from jaspion.sketch import Sketch


# Freeswitch data to connection
freeswitch = {"host": "127.0.0.1", "password": "ClueCon", "port": 8021}

# Create a Sketch instance
default = Sketch("heartbeat")


# Add a handler to Sketch
@default.handle("HEARTBEAT")
def heartbeat(event):
    server = event["FreeSWITCH-Hostname"]
    now = event["Event-Date-Local"]
    print('[%s] Recived a "heartbeat" from %s' % (now, server))


# Create a Jaspion App
app = Jaspion(**freeswitch)

# Add new Sketch to App
app.update(default)


if __name__ == "__main__":
    app.run()