Closed Otoru closed 5 years ago
Hi @Otoru,
greenswitch
allows you to register handlers for any event that freeswitch sends.
Here is one example for handling the HEARTBEAT
event:
import gevent
from greenswitch import InboundESL
con = InboundESL('127.0.0.1', 8021, 'ClueCon')
# handling an event
con.register_handle('HEARTBEAT', lambda event: print('heartbeating', event))
con.connect()
event = con.send('event plain all')
if con.connected:
while True:
try:
gevent.sleep(1)
except KeyboardInterrupt:
con.stop()
break
In case you meant "use greenswitch to wait for the next event", I believe that's not possible.
The code above meets my need very well. A question for what is the gevent.sleep(1)
statement in this code?
The sleep
is to allow other resources "do some work".
Thank you for your help. If new doubts arise I publish again.
For not knowing where to look for examples, I could not build an equivalent of the code below using greeswitch and I need help.
Code: