1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-11 01:59:38 +02:00

First state representing stuff

This commit is contained in:
vanitasvitae 2017-06-19 14:44:35 +02:00
parent 1912ebb8d0
commit e0a54c19d6
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
9 changed files with 221 additions and 18 deletions

View file

@ -27,6 +27,7 @@ import org.jivesoftware.smack.iqrequest.AbstractIqRequestHandler;
import org.jivesoftware.smack.iqrequest.IQRequestHandler.Mode;
import org.jivesoftware.smack.packet.IQ;
import org.jivesoftware.smack.packet.IQ.Type;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.jingle.element.Jingle;
import org.jivesoftware.smackx.jingle.element.JingleAction;
import org.jivesoftware.smackx.jingle.element.JingleContent;
@ -73,7 +74,7 @@ public final class JingleManager extends Manager {
JingleSessionHandler sessionHandler = jingleSessionHandlers.get(fullJidAndSessionId);
if (sessionHandler != null) {
//Handle existing session
return sessionHandler.handleJingleSessionRequest(jingle, jingle.getSid());
return sessionHandler.handleJingleSessionRequest(jingle);
}
if (jingle.getAction() == JingleAction.session_initiate) {
@ -109,4 +110,8 @@ public final class JingleManager extends Manager {
FullJidAndSessionId fullJidAndSessionId = new FullJidAndSessionId(otherJid, sessionId);
return jingleSessionHandlers.remove(fullJidAndSessionId);
}
public static String randomSid() {
return StringUtils.randomString(24);
}
}

View file

@ -324,6 +324,10 @@ public class JingleUtil {
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
public IQ sendContentRejectFileNotAvailable(FullJid recipient, String sessionId, JingleContentDescription description) {
return null; //TODO Later
}
public Jingle createSessionPing(FullJid recipient, String sessionId) {
Jingle.Builder jb = Jingle.getBuilder();
jb.setSessionId(sessionId)
@ -343,6 +347,14 @@ public class JingleUtil {
return connection.createStanzaCollectorAndSend(jingle).nextResultOrThrow();
}
public IQ createAck(Jingle jingle) {
return IQ.createResultIQ(jingle);
}
public void sendAck(Jingle jingle) throws SmackException.NotConnectedException, InterruptedException {
connection.sendStanza(createAck(jingle));
}
public IQ createErrorUnknownSession(Jingle request) {
XMPPError.Builder error = XMPPError.getBuilder();
error.setCondition(XMPPError.Condition.item_not_found)
@ -399,4 +411,13 @@ public class JingleUtil {
throws SmackException.NotConnectedException, InterruptedException {
connection.sendStanza(createErrorOutOfOrder(request));
}
public IQ createErrorMalformedRequest(Jingle request) {
return IQ.createErrorResponse(request, XMPPError.Condition.bad_request);
}
public void sendErrorMalformedRequest(Jingle request)
throws SmackException.NotConnectedException, InterruptedException {
connection.sendStanza(createErrorMalformedRequest(request));
}
}