def originate_call(self, src, dest): ''' Origiante a call from src, I add the technologie to the src cause F1Com protocol don't carry aboit it TODO : Must look for the solution for indicate the technologie ''' tech = "SIP" peer = tech + "/" + src to_json = {"id": "originate", "servername": self._asteriskServer, "type": "dial", "user": "******", "source": peer, "destination": dest} message = json.dumps(to_json) self._redisPublisher.publish("odin_ami_request_channel", message) #originateCall = OriginateCall({'src': src, 'dest': dest}) originateCall = BasicObject("OriginateCall") originateCall.src = src originateCall.dest = dest #Set the key as the source number, the key will be migrate to uniqueid into create channel handler self.originateCalls[src] = originateCall #OriginateCall({'src': src, 'dest': dest}) logger.debug("AMIBridge : Originate call from %s to %s " % (src,dest))
def handler_ami_createparkedcall(self, data): logger.debug("AMIBridge handler_ami_createparkedcall") channel = data['parkedcall']['channel'] parked = self.parkedCalls.get(channel) if not parked : parked = BasicObject("ParkedCall") #populate the parked parked.channel = channel parked.exten = data['parkedcall']['exten'] parked.channelFrom = data['parkedcall']['parkedFrom'] parked.calleridnum = data['parkedcall']['calleridnum'] parked.calleridnumFrom = data['parkedcall']['calleridnumFrom'] parked.timeout = data['parkedcall']['timeout'] parked.calleridname = data['parkedcall']['calleridname'] parked.calleridnameFrom = data['parkedcall']['calleridnameFrom'] self.parkedCalls[channel] = parked
def _createChannel(self, data): # createChannel = data['channel'] uniqueid = createChannel['uniqueid'] channel = createChannel['channel'] if not self.channels.has_key(uniqueid): # newChannel = BasicObject("Channel") newChannel.uniqueid = uniqueid newChannel.channel = channel newChannel.state = createChannel['state'] newChannel.calleridnum = createChannel['calleridnum'] newChannel.calleridname = createChannel['calleridname'] newChannel.monitor = createChannel['monitor'] newChannel.spy = createChannel['spy'] newChannel.starttime = time.time() self.channels[uniqueid] = newChannel else: logger.warning("AMIBridge : Channel %s with unique id %s already exists." %(channel, uniqueid))
def new_call(self, data): uniqueid = data['event']['uniqueid'] logger.debug("CallCenter : CallCenter create a new call for uniqueid [%s] " % (uniqueid)) callref = self._astHelper.add_uniqueid(uniqueid) code = CC_INFO_CODE_1ECOUT extention = data['event']['extention'] callcenter = CC_INCALL_RING caller = data['event']['calleridnum'] newcall = BasicObject('InCall') newcall.callref = callref newcall.extention = extention newcall.caller = caller newcall.post ='' newcall.uniqueid = uniqueid newcall.bridgeduniqueid = '' newcall.channel = data['event']['channel'] self._incalls[uniqueid] = newcall self.__send_callcenter_event(code, extention, callcenter, callref, caller) logger.debug("CallCenter : New call created for uniqueid [%s] extention [%s] caller [%s]" % (uniqueid, extention, caller)) if DUMPOBJECTS: logger.debug("CallCenter : new call :%s", newcall)
def handler_ami_createbridge(self, data): logger.debug("AMIBridge handler_ami_createbridge") uniqueid = data['bridge']['uniqueid'] bridgeduniqueid = data['bridge']['bridgeduniqueid'] if self.originateCalls.has_key(uniqueid): originateCall = self.originateCalls[uniqueid] originateCall.srcChannel = data['bridge']['uniqueid'] originateCall.bridgetChannel = data['bridge']['bridgedchannel'] originateCall.bridgetUniqueId = data['bridge']['bridgeduniqueid'] bridgedStatus = data['bridge']['status'] originateCall.bridgedStatus = bridgedStatus if bridgedStatus == 'Dial': self._send_call_state(0x31, self.originateCalls[uniqueid].dest) else: logger.debug("AMIBridge : handler_ami_createbridge skip to send the status %s to F1" % (bridgedStatus)) else: logger.debug("AMIBridge : handler_ami_createbridge can't find into originate calls") #create bridged call bridgekey = (uniqueid, bridgeduniqueid) if not self.bridgedCalls.has_key(bridgekey): ''' ''' bridge = BasicObject("Bridge") bridge.uniqueid = uniqueid bridge.bridgeduniqueid = data['bridge']['bridgeduniqueid'] bridge.channel = data['bridge']['channel'] bridge.bridgedchannel = data['bridge']['bridgedchannel'] bridge.status = data['bridge']['status'] bridge.dialtime = data['bridge']['dialtime'] #bridge.linktime = data['bridge']['linktime'] self._set_callerid_for_bridge(bridge) if logging.DUMPOBJECTS: logger.debug("Bridge create :%s", bridge) self.bridgedCalls[bridgekey] = bridge #update an incomming call if existe self._callCenter.update_call_from_bridge(bridge) else: logger.warning("AMIBridge : bridge call already existe %s with %s" % (data['bridge']['channel'], data['bridge']['bridgedchannel']))