use of org.jivesoftware.smackx.jingleold.listeners.JingleTransportListener in project Smack by igniterealtime.
the class TransportNegotiator method triggerTransportEstablished.
/**
* Trigger a Transport session established event.
*
* @param local TransportCandidate that has been agreed.
* @param remote TransportCandidate that has been agreed.
* @throws NotConnectedException
* @throws InterruptedException
*/
private void triggerTransportEstablished(TransportCandidate local, TransportCandidate remote) throws NotConnectedException, InterruptedException {
List<JingleListener> listeners = getListenersList();
for (JingleListener li : listeners) {
if (li instanceof JingleTransportListener) {
JingleTransportListener mli = (JingleTransportListener) li;
LOGGER.fine("triggerTransportEstablished " + local.getLocalIp() + ":" + local.getPort() + " <-> " + remote.getIp() + ":" + remote.getPort());
mli.transportEstablished(local, remote);
}
}
}
use of org.jivesoftware.smackx.jingleold.listeners.JingleTransportListener in project Smack by igniterealtime.
the class TransportNegotiator method triggerTransportClosed.
/**
* Trigger a Transport closed event.
*
* @param cand current TransportCandidate that is cancelled.
*/
private void triggerTransportClosed(TransportCandidate cand) {
List<JingleListener> listeners = getListenersList();
for (JingleListener li : listeners) {
if (li instanceof JingleTransportListener) {
JingleTransportListener mli = (JingleTransportListener) li;
mli.transportClosed(cand);
}
}
}
use of org.jivesoftware.smackx.jingleold.listeners.JingleTransportListener in project Smack by igniterealtime.
the class JingleSession method setupListeners.
/**
* Setup the listeners that act on events coming from the lower level negotiators.
*/
public void setupListeners() {
JingleMediaListener jingleMediaListener = new JingleMediaListener() {
@Override
public void mediaClosed(PayloadType cand) {
}
@Override
public void mediaEstablished(PayloadType pt) throws NotConnectedException, InterruptedException {
if (isFullyEstablished()) {
Jingle jout = new Jingle(JingleActionEnum.SESSION_ACCEPT);
// Build up a response packet from each media manager.
for (ContentNegotiator contentNegotiator : contentNegotiators) {
if (contentNegotiator.getNegotiatorState() == JingleNegotiatorState.SUCCEEDED)
jout.addContent(contentNegotiator.getJingleContent());
}
// Send the "accept" and wait for the ACK
addExpectedId(jout.getStanzaId());
sendStanza(jout);
//triggerSessionEstablished();
}
}
};
JingleTransportListener jingleTransportListener = new JingleTransportListener() {
@Override
public void transportEstablished(TransportCandidate local, TransportCandidate remote) throws NotConnectedException, InterruptedException {
if (isFullyEstablished()) {
// CHECKSTYLE:OFF
// Indicate that this session is active.
setSessionState(JingleSessionStateActive.getInstance());
for (ContentNegotiator contentNegotiator : contentNegotiators) {
// CHECKSTYLE:ON
if (contentNegotiator.getNegotiatorState() == JingleNegotiatorState.SUCCEEDED)
contentNegotiator.triggerContentEstablished();
}
if (getSessionState().equals(JingleSessionStatePending.getInstance())) {
Jingle jout = new Jingle(JingleActionEnum.SESSION_ACCEPT);
// Build up a response packet from each media manager.
for (ContentNegotiator contentNegotiator : contentNegotiators) {
if (contentNegotiator.getNegotiatorState() == JingleNegotiatorState.SUCCEEDED)
jout.addContent(contentNegotiator.getJingleContent());
}
// Send the "accept" and wait for the ACK
addExpectedId(jout.getStanzaId());
sendStanza(jout);
}
}
}
@Override
public void transportClosed(TransportCandidate cand) {
}
@Override
public void transportClosedOnError(XMPPException e) {
}
};
addMediaListener(jingleMediaListener);
addTransportListener(jingleTransportListener);
}
Aggregations