mirror of
https://github.com/vanitasvitae/Smack.git
synced 2025-09-10 17:49:38 +02:00
Progress
This commit is contained in:
parent
e6d365fb92
commit
598c193408
5 changed files with 150 additions and 224 deletions
|
@ -16,6 +16,11 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.jivesoftware.smack.Manager;
|
||||
import org.jivesoftware.smack.XMPPConnection;
|
||||
import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
|
||||
|
@ -23,16 +28,12 @@ import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
|
|||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smack.packet.IQ.Type;
|
||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContent;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleContentDescription;
|
||||
import org.jxmpp.jid.FullJid;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.WeakHashMap;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
public final class JingleManager extends Manager {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(JingleManager.class.getName());
|
||||
|
@ -61,7 +62,7 @@ public final class JingleManager extends Manager {
|
|||
public IQ handleIQRequest(IQ iqRequest) {
|
||||
final Jingle jingle = (Jingle) iqRequest;
|
||||
|
||||
if (jingle.getContents().isEmpty()) {
|
||||
if (jingle.getAction() != JingleAction.session_initiate) {
|
||||
Jid from = jingle.getFrom();
|
||||
assert (from != null);
|
||||
FullJid fullFrom = from.asFullJidOrThrow();
|
||||
|
|
|
@ -16,17 +16,29 @@
|
|||
*/
|
||||
package org.jivesoftware.smackx.jingle;
|
||||
|
||||
import org.jivesoftware.smack.packet.IQ;
|
||||
import org.jivesoftware.smackx.jingle.element.Jingle;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleAction;
|
||||
import org.jivesoftware.smackx.jingle.element.JingleReason;
|
||||
import org.jxmpp.jid.Jid;
|
||||
|
||||
// TODO: Is this class still required? If not, then remove it.
|
||||
public class JingleSession {
|
||||
|
||||
public enum State {
|
||||
pending,
|
||||
active,
|
||||
;
|
||||
}
|
||||
|
||||
private final Jid initiator;
|
||||
|
||||
private final Jid responder;
|
||||
|
||||
private final String sid;
|
||||
|
||||
private State state = State.pending;
|
||||
|
||||
public JingleSession(Jid initiator, Jid responder, String sid) {
|
||||
this.initiator = initiator;
|
||||
this.responder = responder;
|
||||
|
@ -53,6 +65,14 @@ public class JingleSession {
|
|||
return responder;
|
||||
}
|
||||
|
||||
public void setState(State state) {
|
||||
this.state = state;
|
||||
}
|
||||
|
||||
public State getState() {
|
||||
return state;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object other) {
|
||||
if (!(other instanceof JingleSession)) {
|
||||
|
@ -63,4 +83,13 @@ public class JingleSession {
|
|||
return initiator.equals(otherJingleSession.initiator) && responder.equals(otherJingleSession.responder)
|
||||
&& sid.equals(otherJingleSession.sid);
|
||||
}
|
||||
|
||||
IQ terminateSuccessfully() {
|
||||
Jingle.Builder builder = Jingle.getBuilder();
|
||||
builder.setAction(JingleAction.session_terminate);
|
||||
builder.setSessionId(getSid());
|
||||
builder.setReason(JingleReason.Reason.success);
|
||||
|
||||
return builder.build();
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue