mirror of
https://github.com/signalwire/freeswitch.git
synced 2026-07-06 12:21:49 +00:00
fix the evil snake (again)
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@9051 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
@@ -0,0 +1,61 @@
|
||||
import os
|
||||
from freeswitch import *
|
||||
|
||||
# HANGUP HOOK
|
||||
#
|
||||
# session is a session object
|
||||
# what is "hangup" or "transfer"
|
||||
# if you pass an extra arg to setInputCallback then append 'arg' to get that value
|
||||
# def hangup_hook(session, what, arg):
|
||||
def hangup_hook(session, what):
|
||||
|
||||
consoleLog("info","hangup hook for %s!!\n\n" % what)
|
||||
return
|
||||
|
||||
|
||||
# INPUT CALLBACK
|
||||
#
|
||||
# session is a session object
|
||||
# what is "dtmf" or "event"
|
||||
# obj is a dtmf object or an event object depending on the 'what' var.
|
||||
# if you pass an extra arg to setInputCallback then append 'arg' to get that value
|
||||
# def input_callback(session, what, obj, arg):
|
||||
def input_callback(session, what, obj):
|
||||
|
||||
if (what == "dtmf"):
|
||||
consoleLog("info", what + " " + obj.digit + "\n")
|
||||
else:
|
||||
consoleLog("info", what + " " + obj.serialize() + "\n")
|
||||
return "pause"
|
||||
|
||||
# APPLICATION
|
||||
#
|
||||
# default name for apps is "handler" it can be overridden with <modname>::<function>
|
||||
# session is a session object
|
||||
# args is all the args passed after the module name
|
||||
def handler(session, args):
|
||||
|
||||
session.answer()
|
||||
session.setHangupHook(hangup_hook)
|
||||
session.setInputCallback(input_callback)
|
||||
session.execute("playback", session.getVariable("hold_music"))
|
||||
|
||||
# FSAPI CALL FROM CLI, DP HTTP etc
|
||||
#
|
||||
# default name for python FSAPI is "fsapi" it can be overridden with <modname>::<function>
|
||||
# stream is a switch_stream, anything written with stream.write() is returned to the caller
|
||||
# env is a switch_event
|
||||
# args is all the args passed after the module name
|
||||
# session is a session object when called from the dial plan or the string "na" when not.
|
||||
def fsapi(session, stream, env, args):
|
||||
|
||||
stream.write("w00t!\n" + env.serialize())
|
||||
|
||||
|
||||
# RUN A FUNCTION IN A THREAD
|
||||
#
|
||||
# default name for pyrun is "runtime" it can be overridden with <modname>::<function>
|
||||
# args is all the args passed after the module name
|
||||
def runtime(args):
|
||||
|
||||
print args + "\n"
|
||||
Reference in New Issue
Block a user