public void onStartServiceEvent( javax.slee.serviceactivity.ServiceStartedEvent event, ActivityContextInterface aci) { tracer.info("Retreiving www.telestax.com..."); try { HttpClientNIORequestActivity activity = httpClientRA.execute( new HttpGet("http://www.telestax.com"), null, System.currentTimeMillis()); httpClientACIF.getActivityContextInterface(activity).attach( sbbContext.getSbbLocalObject()); } catch (Exception e) { tracer.severe("failed to retrieve webpage", e); } }
/** * Simple method to create JDBC activity and execute given task. * * @param queryJDBCTask */ private void executeTask(DataSourceJdbcTask jdbcTask) { JdbcActivity jdbcActivity = jdbcRA.createActivity(); ActivityContextInterface jdbcACI = jdbcACIF .getActivityContextInterface(jdbcActivity); jdbcACI.attach(sbbContextExt.getSbbLocalObject()); jdbcActivity.execute(jdbcTask); }
/** * Simple method to create JDBC activity and execute given task. * * @param jdbcTask */ private void executeTask(SimpleJdbcTask jdbcTask) { JdbcActivity jdbcActivity = jdbcRA.createActivity(); ActivityContextInterface jdbcACI = jdbcACIF.getActivityContextInterface(jdbcActivity); jdbcACI.attach(sbbContextExt.getSbbLocalObject()); jdbcActivity.execute(jdbcTask); }
/** * Init the xmpp connection to GOOGLE TALK when the service is activated by * SLEE * * @param event * @param aci */ public void onStartServiceEvent( javax.slee.serviceactivity.ServiceStartedEvent event, ActivityContextInterface aci) { try { // connect to google talk xmpp server XmppConnection connection = xmppSbbInterface.connectClient( connectionID, serviceHost, servicePort, serviceName, username, password, resource, Arrays .asList(packetsToListen)); xmppActivityContextInterfaceFactory.getActivityContextInterface( connection).attach(sbbContext.getSbbLocalObject()); } catch (XMPPException e) { tracer.severe("Connection to server failed!",e); } }
public RatingInfo getRateForServiceAsync(HashMap params) { String sessionIdFromRequest = params.get("SessionId").toString(); HttpClientActivity clientActivity = null; try { clientActivity = raSbbInterface.createHttpClientActivity(true, null); } catch (StartActivityException e) { tracer.severe("[xx] Failed creating HTTP Client Activity to send HTTP Request to Rating Engine."); return new RatingInfo(-1, sessionIdFromRequest); } ActivityContextInterface clientAci = httpClientAci.getActivityContextInterface(clientActivity); clientAci.attach(sbbContext.getSbbLocalObject()); params.put("startTime", System.currentTimeMillis()); HttpPost httpPost = buildHTTPRequest(params); // Asynchronous call clientActivity.execute(httpPost, params); tracer.info("[>>] Sent HTTP Request to Rating Client in asynchronous mode."); return null; }
public void onInitMedia(InteropCustomEvent event, ActivityContextInterface ac) { logger.info("****** org.mobicents.slee.service.interopdemo.INIT_MEDIA ******* "); logger.info("InteropSbb: " + this + ": received an INIT_MEDIA event. username = " + event.getBoothNumber() + ". sdpContent = " + new String(event.getSdpContent())); this.setInteropCustomEvent(event); MsConnection msConnection = msProvider.createSession().createNetworkConnection(PR_ENDPOINT_NAME); try { ActivityContextInterface msAci = mediaAcif.getActivityContextInterface(msConnection); msAci.attach(this.getSbbContext().getSbbLocalObject()); } catch (Exception ex) { logger.error("Internal server error", ex); return; } msConnection.modify("$", new String(event.getSdpContent())); }
/** * (Non Java-doc). * * @see org.mobicents.examples.media.Demo#startConversation(String, ActivityContextInterface). */ public void startDemo(String endpointName) { this.setUserEndpoint(endpointName); ChildRelation childRelation = this.getAnnouncementSbb(); try { Announcement announcement = (Announcement) childRelation.create(); sbbContext.getActivities()[0].attach(announcement); List sequence = new ArrayList(); sequence.add(WELCOME_MSG); announcement.play(endpointName, sequence, false); } catch (CreateException e) { logger.error("Unexpected error, Caused by", e); MsConnection connection = (MsConnection) sbbContext.getActivities()[0].getActivity(); connection.release(); } }
public void onAnnouncementComplete(MsLinkEvent evt, ActivityContextInterface aci) { try { ChildRelation childRelation = this.getLoopbackSbb(); Conversation loopback = (Conversation) childRelation.create(); logger.info("Starting loopback"); sbbContext.getActivities()[0].attach(loopback); loopback.startConversation(this.getUserEndpoint()); } catch (CreateException e) { MsConnection connection = (MsConnection) sbbContext.getActivities()[0].getActivity(); connection.release(); } }
/** * Starts dialog. * * @param endpointName the user's endpoint. * @param aci the user's activity context interface. */ public void startConversation(String endpointName) { logger.info("Joining " + endpointName + " with " + LOOP_ENDPOINT); MsConnection connection = (MsConnection) sbbContext.getActivities()[0].getActivity(); MsSession session = connection.getSession(); MsLink link = session.createLink(MsLinkMode.FULL_DUPLEX); ActivityContextInterface linkActivity = null; try { linkActivity = mediaAcif.getActivityContextInterface(link); } catch (UnrecognizedActivityException ex) { } linkActivity.attach(sbbContext.getSbbLocalObject()); link.join(endpointName, LOOP_ENDPOINT); }
private void initDtmfDetector(MsLink link, String endpointName) { MsEventFactory eventFactory = msProvider .getEventFactory(); try { ActivityContextInterface dtmfAci = mediaAcif .getActivityContextInterface(link.getSession()); dtmfAci.attach(getSbbContext().getSbbLocalObject()); MsDtmfRequestedEvent dtmf = (MsDtmfRequestedEvent) eventFactory.createRequestedEvent(DTMF.TONE); MsRequestedSignal[] signals = new MsRequestedSignal[] {}; MsRequestedEvent[] events = new MsRequestedEvent[] { dtmf }; link.getEndpoints()[1].execute(signals, events, link); } catch (UnrecognizedActivityException e) { logger.error("Internal Server Erro", e); } }
public void onLinkCreated(MsLinkEvent evt, ActivityContextInterface aci) { logger.info("--------onLinkCreated------------"); MsLink link = evt.getSource(); String announcementEndpoint = link.getEndpoints()[1]; String endpointName = null; if (this.getEndpointName() == null) { this.setEndpointName(link.getEndpoints()[0]); } if (this.getAnnouncementEndpointName() == null) { this.setAnnouncementEndpointName(announcementEndpoint); } endpointName = this.getEndpointName(); logger.info("endpoint name: " + endpointName); logger.info("Announcement endpoint: " + announcementEndpoint); MsSignalGenerator generator = msProvider .getSignalGenerator(announcementEndpoint); try { ActivityContextInterface generatorActivity = mediaAcif .getActivityContextInterface(generator); generatorActivity.attach(getSbbContext().getSbbLocalObject()); String announcementFile = (getClass().getResource(orderDeliveryDate)).toString(); generator.apply(EventID.PLAY, new String[] { announcementFile }); //this.initDtmfDetector(getConnection(), endpointName); } catch (UnrecognizedActivityException e) { e.printStackTrace(); } }
/** * Private methods */ private void sendXmlPayload(byte[] data) throws Exception { HttpClientActivity httpClientActivity = this.getHTTPClientActivity(); if (httpClientActivity == null) { httpClientActivity = this.httpClientProvider.createHttpClientActivity(false, null); this.httpClientActivityContextInterfaceFactory.getActivityContextInterface(httpClientActivity).attach( this.sbbContext.getSbbLocalObject()); } this.httpClientActivityContextInterfaceFactory.getActivityContextInterface(httpClientActivity).attach( this.sbbContext.getSbbLocalObject()); String route = this.getNetworkRoutingRule().getRuleUrl(); HttpPost uriRequest = createRequest(route, null, ACCEPTED_CONTENT_TYPE, null); // NOTE: here we assume that its text/xml utf8 encoded... bum. pushContent(uriRequest, ACCEPTED_CONTENT_TYPE, CONTENT_ENCODING, data); if (logger.isFineEnabled()) { logger.fine("Executing HttpPost=" + uriRequest + "\n" + new String(data)); } httpClientActivity.execute(uriRequest, null); }
private void finishMediaSessionSetup( ActivityContextInterface networkConnectionAci) throws MsControlException { NetworkConnection connection = (NetworkConnection) networkConnectionAci .getActivity(); MediaSession session = connection.getMediaSession(); MediaGroup mediaGroup = session .createMediaGroup(MediaGroup.PLAYER_RECORDER_SIGNALDETECTOR); connection.joinInitiate(Direction.DUPLEX, mediaGroup, "context"); ActivityContextInterface mediaGroupACI = mscRaAciFactory .getActivityContextInterface(mediaGroup); mediaGroupACI.attach(sbbContext.getSbbLocalObject()); setMediaGroupACI(mediaGroupACI); }
private void finishMediaSessionSetup( ActivityContextInterface networkConnectionAci) throws MsControlException { NetworkConnection connection = (NetworkConnection) networkConnectionAci .getActivity(); MediaSession session = connection.getMediaSession(); MediaGroup mediaGroup = session .createMediaGroup(MediaGroup.PLAYER_RECORDER_SIGNALDETECTOR); connection.joinInitiate(Direction.DUPLEX, mediaGroup, "context"); ActivityContextInterface mediaGroupACI = mscRaAciFactory .getActivityContextInterface(mediaGroup); mediaGroupACI.attach(sbbContext.getSbbLocalObject()); setMediaGroupACI(mediaGroupACI); }
private void initialMediaSessionSetup(ServerTransaction serverTransaction) throws MsControlException { // create media session MediaSession session = msRaSbbInterface.createMediaSession(); ActivityContextInterface mediaSessionACI = mscRaAciFactory .getActivityContextInterface(session); SbbLocalObject sbbLocalObject = sbbContext.getSbbLocalObject(); mediaSessionACI.attach(sbbLocalObject); // store the media session aci in a cmp shortcut setMediaSessionACI(mediaSessionACI); tracer.info("Created media session: " + session); // create network connection NetworkConnection connection = session .createNetworkConnection(NetworkConnection.BASIC); ActivityContextInterface connectionACI = mscRaAciFactory .getActivityContextInterface(connection); connectionACI.attach(sbbLocalObject); // store the network connection aci in a cmp shortcut setNetworkConnectionACI(connectionACI); tracer.info("Created network connection: " + connection); // process the received sdp SdpPortManager sdpManager = connection.getSdpPortManager(); tracer.info("Created SDP Manager, sending client sdp..."); sdpManager.processSdpOffer((byte[]) serverTransaction.getRequest() .getContent()); }
public void onInviteEvent(javax.sip.RequestEvent requestEvent, ActivityContextInterface aci) { try { ServerTransaction serverTransaction = requestEvent.getServerTransaction(); // send 100 // serverTransaction.sendResponse(messageFactory.createResponse(100,requestEvent.getRequest())); // create dialog and attach this entity to it's aci DialogActivity dialog = (DialogActivity) sipFactoryProvider.getNewDialog(serverTransaction); sipActivityContextInterfaceFactory.getActivityContextInterface(dialog).attach(this.sbbContext.getSbbLocalObject()); // send 200 ok Response response = messageFactory .createResponse(Response.OK,requestEvent.getRequest()); response.addHeader(getContactHeader()); ((ToHeader)response.getHeader(ToHeader.NAME)).setTag(Utils.getInstance().generateTag()); serverTransaction.sendResponse(response); } catch (Exception ex) { ex.printStackTrace(); } }
public void onConnectionCreated(MsConnectionEvent evt, ActivityContextInterface aci) { log.info("--------------onConnectionCreated--------------"); MsConnection connection = evt.getConnection(); log.info("Created RTP connection [" + connection.getEndpoint() + "]"); try { Dialog dialog = sipUtils.getDialog(getResponseEventCmp()); Request ackRequest = sipUtils.buildAck(dialog, connection .getLocalDescriptor()); dialog.sendAck(ackRequest); } catch (SipException e) { e.printStackTrace(); } MsSession session = connection.getSession(); MsLink link = session.createLink(MsLinkMode.FULL_DUPLEX); ActivityContextInterface linkActivity = null; try { linkActivity = mediaAcif.getActivityContextInterface(link); } catch (UnrecognizedActivityException ex) { ex.printStackTrace(); } linkActivity.attach(getParentCmp()); link.join(connection.getEndpoint(), ANNOUNCEMENT_ENDPOINT); }
private void sendSRI(String destinationAddress, int ton, int npi, MAPApplicationContext mapApplicationContext, CorrelationIdValue correlationIdValue) { // Send out SRI MAPDialogSms mapDialogSms = null; try { // 1. Create Dialog first and add the SRI request to it mapDialogSms = this.setupRoutingInfoForSMRequestIndication(destinationAddress, ton, npi, mapApplicationContext, correlationIdValue.getNetworkId()); // 2. Create the ACI and attach this SBB ActivityContextInterface sriDialogACI = this.mapAcif.getActivityContextInterface(mapDialogSms); sriDialogACI.attach(this.sbbContext.getSbbLocalObject()); // 3. Finally send the request mapDialogSms.send(); } catch (MAPException e) { if (mapDialogSms != null) { mapDialogSms.release(); } String reason = "Home routing: HrSriClientSbb: MAPException when sending SRI from sendSRI(): " + e.toString(); this.logger.severe(reason, e); this.returnSriFailure(correlationIdValue, null, reason); } }
private void initialSipSessionSetup(RequestEvent event, ActivityContextInterface aci) throws ParseException, SipException, InvalidArgumentException { // store the server tx aci in a cmp shortcut setServerTransactionACI(aci); // send trying response ServerTransaction serverTransaction = event.getServerTransaction(); Response response = sipRaSbbInterface .getMessageFactory() .createResponse(Response.TRYING, serverTransaction.getRequest()); serverTransaction.sendResponse(response); // create sip dialog and attach to its activity Dialog dialog = sipRaSbbInterface.getNewDialog(serverTransaction); ActivityContextInterface dialogAci = sipRaAciFactory .getActivityContextInterface((DialogActivity) dialog); dialogAci.attach(sbbContext.getSbbLocalObject()); // store the dialog aci in a cmp shortcut setDialogACI(dialogAci); }
private void initialSipSessionSetup(RequestEvent event, ActivityContextInterface aci) throws ParseException, SipException, InvalidArgumentException { // store the server tx aci in a cmp shortcut setServerTransactionACI(aci); // send trying response ServerTransaction serverTransaction = event.getServerTransaction(); Response response = sipRaSbbInterface .getMessageFactory() .createResponse(Response.TRYING, serverTransaction.getRequest()); serverTransaction.sendResponse(response); // create sip dialog and attach to its activity Dialog dialog = sipRaSbbInterface.getNewDialog(serverTransaction); ActivityContextInterface dialogAci = sipRaAciFactory .getActivityContextInterface((DialogActivity) dialog); dialogAci.attach(sbbContext.getSbbLocalObject()); // store the dialog aci in a cmp shortcut setDialogACI(dialogAci); }