add server example for python thanks anm
git-svn-id: http://svn.freeswitch.org/svn/freeswitch/trunk@12205 d0543943-73ff-0310-b7d9-9358b9ac24b2
This commit is contained in:
parent
4371f56802
commit
4a334536a2
|
@ -0,0 +1,66 @@
|
||||||
|
#!/usr/bin/env python
|
||||||
|
|
||||||
|
import SocketServer
|
||||||
|
import pickle
|
||||||
|
from ESL import *
|
||||||
|
|
||||||
|
#eslSetLogLevel(7)
|
||||||
|
|
||||||
|
class ESLRequestHandler(SocketServer.BaseRequestHandler ):
|
||||||
|
def setup(self):
|
||||||
|
print self.client_address, 'connected!'
|
||||||
|
|
||||||
|
fd = self.request.fileno()
|
||||||
|
print fd
|
||||||
|
|
||||||
|
con = ESLconnection(fd)
|
||||||
|
print "Connected: "
|
||||||
|
print con.connected()
|
||||||
|
if con.connected():
|
||||||
|
|
||||||
|
info = con.getInfo()
|
||||||
|
|
||||||
|
uuid = info.getHeader("unique-id")
|
||||||
|
print uuid
|
||||||
|
con.execute("answer", "", uuid)
|
||||||
|
con.execute("playback", "/ram/swimp.raw", uuid);
|
||||||
|
|
||||||
|
#server host is a tuple ('host', port)
|
||||||
|
server = SocketServer.ThreadingTCPServer(('', 8040), ESLRequestHandler)
|
||||||
|
server.serve_forever()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
#require ESL;
|
||||||
|
#use IO::Socket::INET;
|
||||||
|
#
|
||||||
|
#my $ip = "127.0.0.1";
|
||||||
|
#my $sock = new IO::Socket::INET ( LocalHost => $ip, LocalPort => '8040', Proto => 'tcp', Listen => 1, Reuse => 1 );
|
||||||
|
#die "Could not create socket: $!\n" unless $sock;
|
||||||
|
#
|
||||||
|
#for(;;) {
|
||||||
|
# my $new_sock = $sock->accept();
|
||||||
|
# my $pid = fork();
|
||||||
|
# if ($pid) {
|
||||||
|
# close($new_sock);
|
||||||
|
# next;
|
||||||
|
# }
|
||||||
|
#
|
||||||
|
# my $host = $new_sock->sockhost();
|
||||||
|
# my $fd = fileno($new_sock);
|
||||||
|
#
|
||||||
|
# my $con = new ESL::ESLconnection($fd);
|
||||||
|
# my $info = $con->getInfo();
|
||||||
|
#
|
||||||
|
# print $info->serialize();
|
||||||
|
#
|
||||||
|
# my $uuid = $info->getHeader("unique-id");
|
||||||
|
#
|
||||||
|
# $con->execute("answer", "", $uuid);
|
||||||
|
# $con->execute("playback", "/ram/swimp.raw", $uuid);
|
||||||
|
#
|
||||||
|
# close($new_sock);
|
||||||
|
#}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue