XmppClientToServerTransport.java

  1. /**
  2.  *
  3.  * Copyright 2019-2021 Florian Schmaus
  4.  *
  5.  * Licensed under the Apache License, Version 2.0 (the "License");
  6.  * you may not use this file except in compliance with the License.
  7.  * You may obtain a copy of the License at
  8.  *
  9.  *     http://www.apache.org/licenses/LICENSE-2.0
  10.  *
  11.  * Unless required by applicable law or agreed to in writing, software
  12.  * distributed under the License is distributed on an "AS IS" BASIS,
  13.  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14.  * See the License for the specific language governing permissions and
  15.  * limitations under the License.
  16.  */
  17. package org.jivesoftware.smack.c2s;

  18. import java.util.List;

  19. import javax.net.ssl.SSLSession;

  20. import org.jivesoftware.smack.SmackFuture;
  21. import org.jivesoftware.smack.c2s.internal.ModularXmppClientToServerConnectionInternal;

  22. public abstract class XmppClientToServerTransport {

  23.     protected final ModularXmppClientToServerConnectionInternal connectionInternal;

  24.     protected XmppClientToServerTransport(ModularXmppClientToServerConnectionInternal connectionInternal) {
  25.         this.connectionInternal = connectionInternal;
  26.     }

  27.     protected abstract void resetDiscoveredConnectionEndpoints();

  28.     protected abstract List<SmackFuture<LookupConnectionEndpointsResult, Exception>> lookupConnectionEndpoints();

  29.     protected abstract void loadConnectionEndpoints(LookupConnectionEndpointsSuccess lookupConnectionEndpointsSuccess);

  30.     public abstract boolean hasUseableConnectionEndpoints();

  31.     /**
  32.      * Notify the transport that new outgoing data is available. Usually this method does not need to be called
  33.      * explicitly, only if the filters are modified so that they potentially produced new data.
  34.      */
  35.     protected abstract void afterFiltersClosed();

  36.     /**
  37.      * Called by the CloseConnection state.
  38.      */
  39.     protected abstract void disconnect();

  40.     protected abstract void notifyAboutNewOutgoingElements();

  41.     public abstract SSLSession getSslSession();

  42.     public boolean isTransportSecured() {
  43.         return getSslSession() != null;
  44.     }

  45.     public abstract StreamOpenAndCloseFactory getStreamOpenAndCloseFactory();

  46.     public abstract Stats getStats();

  47.     public abstract static class Stats {
  48.     }

  49.     protected interface LookupConnectionEndpointsResult {
  50.     }

  51.     protected interface LookupConnectionEndpointsSuccess extends LookupConnectionEndpointsResult {
  52.     }

  53.     public interface LookupConnectionEndpointsFailed extends LookupConnectionEndpointsResult {
  54.         // TODO: Add something like getExceptions() or getConnectionExceptions()?
  55.     }

  56. }