Search in sources :

Example 16 with EslMessage

use of org.freeswitch.esl.client.transport.message.EslMessage in project bigbluebutton by bigbluebutton.

the class SimpleHangupOutboundHandler method hangupCall.

private void hangupCall(Channel channel) {
    SendMsg hangupMsg = new SendMsg();
    hangupMsg.addCallCommand("execute");
    hangupMsg.addExecuteAppName("hangup");
    EslMessage response = sendSyncMultiLineCommand(channel, hangupMsg.getMsgLines());
    if (response.getHeaderValue(Name.REPLY_TEXT).startsWith("+OK")) {
        log.info("Call hangup successful");
    } else {
        log.error("Call hangup failed: [{}}", response.getHeaderValue(Name.REPLY_TEXT));
    }
}
Also used : SendMsg(org.freeswitch.esl.client.transport.SendMsg) EslMessage(org.freeswitch.esl.client.transport.message.EslMessage)

Example 17 with EslMessage

use of org.freeswitch.esl.client.transport.message.EslMessage in project bigbluebutton by bigbluebutton.

the class ClientTest method do_connect.

@Test
public void do_connect() throws InterruptedException {
    Client client = new Client();
    client.addEventListener(new IEslEventListener() {

        public void eventReceived(EslEvent event) {
            log.info("Event received [{}]", event);
        }

        public void backgroundJobResultReceived(EslEvent event) {
            log.info("Background job result received [{}]", event);
        }

        public void conferenceEventJoin(String uniqueId, String confName, int confSize, EslEvent event) {
            log.info("Event received [{}]", event);
        }

        public void conferenceEventLeave(String uniqueId, String confName, int confSize, EslEvent event) {
            log.info("Event received [{}]", event);
        }

        public void conferenceEventMute(String uniqueId, String confName, int confSize, EslEvent event) {
            log.info("Event received [{}]", event);
        }

        public void conferenceEventUnMute(String uniqueId, String confName, int confSize, EslEvent event) {
            log.info("Event received [{}]", event);
        }

        public void conferenceEventAction(String uniqueId, String confName, int confSize, String action, EslEvent event) {
            log.info("Event received [{}]", event);
        }

        public void conferenceEventTransfer(String uniqueId, String confName, int confSize, EslEvent event) {
            log.info("Event received [{}]", event);
        }

        public void conferenceEventThreadRun(String uniqueId, String confName, int confSize, EslEvent event) {
            log.info("Event received [{}]", event);
        }

        public void conferenceEventPlayFile(String uniqueId, String confName, int confSize, EslEvent event) {
            log.info("Event received [{}]", event);
        }

        public void exceptionCaught(ExceptionEvent e) {
            log.info("exception received [{}]", e);
        }
    });
    log.info("Client connecting ..");
    try {
        client.connect(host, port, password, 2);
    } catch (InboundConnectionFailure e) {
        log.error("Connect failed", e);
        return;
    }
    log.info("Client connected ..");
    //      client.setEventSubscriptions( "plain", "heartbeat CHANNEL_CREATE CHANNEL_DESTROY BACKGROUND_JOB" );
    client.setEventSubscriptions("plain", "all");
    client.addEventFilter("Event-Name", "heartbeat");
    client.cancelEventSubscriptions();
    client.setEventSubscriptions("plain", "all");
    client.addEventFilter("Event-Name", "heartbeat");
    client.addEventFilter("Event-Name", "channel_create");
    client.addEventFilter("Event-Name", "background_job");
    client.sendSyncApiCommand("echo", "Foo foo bar");
    //        client.sendSyncCommand( "originate", "sofia/internal/101@192.168.100.201! sofia/internal/102@192.168.100.201!" );
    //        client.sendSyncApiCommand( "sofia status", "" );
    String jobId = client.sendAsyncApiCommand("status", "");
    log.info("Job id [{}] for [status]", jobId);
    client.sendSyncApiCommand("version", "");
    //        client.sendAsyncApiCommand( "status", "" );
    //        client.sendSyncApiCommand( "sofia status", "" );
    //        client.sendAsyncApiCommand( "status", "" );
    EslMessage response = client.sendSyncApiCommand("sofia status", "");
    log.info("sofia status = [{}]", response.getBodyLines().get(3));
    // wait to see the heartbeat events arrive
    Thread.sleep(25000);
    client.close();
}
Also used : EslEvent(org.freeswitch.esl.client.transport.event.EslEvent) IEslEventListener(org.freeswitch.esl.client.IEslEventListener) EslMessage(org.freeswitch.esl.client.transport.message.EslMessage) Client(org.freeswitch.esl.client.inbound.Client) InboundConnectionFailure(org.freeswitch.esl.client.inbound.InboundConnectionFailure) Test(org.junit.Test)

Example 18 with EslMessage

use of org.freeswitch.esl.client.transport.message.EslMessage in project bigbluebutton by bigbluebutton.

the class ClientTest method sofia_contact.

@Test
public void sofia_contact() {
    Client client = new Client();
    try {
        client.connect(host, port, password, 2);
    } catch (InboundConnectionFailure e) {
        log.error("Connect failed", e);
        return;
    }
    EslMessage response = client.sendSyncApiCommand("sofia_contact", "internal/102@192.168.100.201");
    log.info("Response to 'sofia_contact': [{}]", response);
    for (Entry<Name, String> header : response.getHeaders().entrySet()) {
        log.info(" * header [{}]", header);
    }
    for (String bodyLine : response.getBodyLines()) {
        log.info(" * body [{}]", bodyLine);
    }
    client.close();
}
Also used : EslMessage(org.freeswitch.esl.client.transport.message.EslMessage) Client(org.freeswitch.esl.client.inbound.Client) InboundConnectionFailure(org.freeswitch.esl.client.inbound.InboundConnectionFailure) Name(org.freeswitch.esl.client.transport.message.EslHeaders.Name) Test(org.junit.Test)

Example 19 with EslMessage

use of org.freeswitch.esl.client.transport.message.EslMessage in project bigbluebutton by bigbluebutton.

the class ConnectionManager method broadcast.

public void broadcast(BroadcastConferenceCommand rcc) {
    Client c = manager.getESLClient();
    if (c.canSend()) {
        EslMessage response = c.sendSyncApiCommand(rcc.getCommand(), rcc.getCommandArgs());
        rcc.handleResponse(response, conferenceEventListener);
    }
}
Also used : EslMessage(org.freeswitch.esl.client.transport.message.EslMessage) Client(org.freeswitch.esl.client.inbound.Client)

Example 20 with EslMessage

use of org.freeswitch.esl.client.transport.message.EslMessage in project bigbluebutton by bigbluebutton.

the class ConnectionManager method getUsers.

public void getUsers(GetAllUsersCommand prc) {
    Client c = manager.getESLClient();
    if (c.canSend()) {
        EslMessage response = c.sendSyncApiCommand(prc.getCommand(), prc.getCommandArgs());
        prc.handleResponse(response, conferenceEventListener);
    }
}
Also used : EslMessage(org.freeswitch.esl.client.transport.message.EslMessage) Client(org.freeswitch.esl.client.inbound.Client)

Aggregations

EslMessage (org.freeswitch.esl.client.transport.message.EslMessage)21 CommandResponse (org.freeswitch.esl.client.transport.CommandResponse)9 Client (org.freeswitch.esl.client.inbound.Client)7 EslEvent (org.freeswitch.esl.client.transport.event.EslEvent)3 InboundConnectionFailure (org.freeswitch.esl.client.inbound.InboundConnectionFailure)2 Test (org.junit.Test)2 UnsupportedEncodingException (java.io.UnsupportedEncodingException)1 IEslEventListener (org.freeswitch.esl.client.IEslEventListener)1 SendMsg (org.freeswitch.esl.client.transport.SendMsg)1 Name (org.freeswitch.esl.client.transport.message.EslHeaders.Name)1 FreeswitchBindingProvider (org.openhab.binding.freeswitch.FreeswitchBindingProvider)1 ConfigurationException (org.osgi.service.cm.ConfigurationException)1