1
0
Fork 0
mirror of https://github.com/vanitasvitae/Smack.git synced 2025-09-12 18:49:39 +02:00

Proper Statemachine

This commit is contained in:
vanitasvitae 2017-06-11 02:52:34 +02:00
parent 4d11422335
commit 7a9b819b18
Signed by: vanitasvitae
GPG key ID: 62BEE9264BF17311
18 changed files with 816 additions and 584 deletions

View file

@ -79,7 +79,7 @@ public final class JingleManager extends Manager {
.addExtension(JingleError.UNKNOWN_SESSION);
return IQ.createErrorResponse(jingle, errorBuilder);
}
return jingleSessionHandler.handleJingleSessionRequest(jingle, jingle.getSessionId());
return jingleSessionHandler.handleJingleSessionRequest(jingle);
}
if (jingle.getContents().size() > 1) {

View file

@ -22,7 +22,7 @@ import org.jivesoftware.smackx.jingle.element.Jingle;
public interface JingleSessionHandler {
IQ handleJingleSessionRequest(Jingle jingle, String sessionId);
IQ handleJingleSessionRequest(Jingle jingle);
XMPPConnection getConnection();

View file

@ -1,10 +1,26 @@
/**
*
* Copyright © 2017 Paul Schaub
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.jingle;
import org.jivesoftware.smackx.bytestreams.BytestreamSession;
import org.jivesoftware.smackx.jingle.exception.JingleTransportFailureException;
/**
* Created by vanitas on 10.06.17.
* Callback that's used to establish BytestreamSessions from transport methods.
*/
public interface JingleTransportEstablishedCallback {
void onSessionEstablished(BytestreamSession bytestreamSession);

View file

@ -1,17 +1,37 @@
/**
*
* Copyright © 2017 Paul Schaub
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.jingle;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smackx.jingle.element.Jingle;
import org.jivesoftware.smackx.jingle.element.JingleContent;
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
/**
* Handler for JingleTransports
* Handler for JingleTransports.
*/
public interface JingleTransportHandler<D extends JingleContentTransport> {
void establishOutgoingSession(Jingle request, JingleTransportEstablishedCallback callback);
void establishOutgoingSession(JingleManager.FullJidAndSessionId fullJidAndSessionId,
JingleContent content,
JingleTransportEstablishedCallback callback);
void establishIncomingSession(Jingle request, JingleTransportEstablishedCallback callback);
void establishIncomingSession(JingleManager.FullJidAndSessionId fullJidAndSessionId,
JingleContent content,
JingleTransportEstablishedCallback callback);
XMPPConnection getConnection();
}

View file

@ -25,6 +25,7 @@ import org.jivesoftware.smack.Manager;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.util.StringUtils;
import org.jivesoftware.smackx.jingle.element.Jingle;
import org.jivesoftware.smackx.jingle.element.JingleContentTransport;
import org.jivesoftware.smackx.jingle.exception.UnsupportedJingleTransportException;
/**
@ -49,6 +50,18 @@ public final class JingleTransportManager extends Manager {
return manager;
}
public static AbstractJingleTransportManager<?> getJingleContentTransportManager(XMPPConnection connection, String namespace) throws UnsupportedJingleTransportException {
return getInstanceFor(connection).getJingleContentTransportManager(namespace);
}
public static AbstractJingleTransportManager<?> getJingleContentTransportManager(XMPPConnection connection, Jingle jingle) throws UnsupportedJingleTransportException {
return getInstanceFor(connection).getJingleContentTransportManager(jingle);
}
public static AbstractJingleTransportManager<?> getJingleContentTransportManager(XMPPConnection connection, JingleContentTransport transport) throws UnsupportedJingleTransportException {
return getInstanceFor(connection).getJingleContentTransportManager(transport.getNamespace());
}
public AbstractJingleTransportManager<?> getJingleContentTransportManager(String namespace) throws UnsupportedJingleTransportException {
AbstractJingleTransportManager<?> manager = contentTransportManagers.get(namespace);
if (manager == null) {

View file

@ -1,7 +1,23 @@
/**
*
* Copyright © 2017 Paul Schaub
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package org.jivesoftware.smackx.jingle.exception;
/**
* Created by vanitas on 10.06.17.
* Exception that gets thrown when establishing a session using a transport fails.
*/
public class JingleTransportFailureException extends Exception {