001/** 002 * 003 * Copyright 2019-2021 Florian Schmaus 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 */ 017package org.jivesoftware.smack.c2s; 018 019import java.util.List; 020 021import javax.net.ssl.SSLSession; 022 023import org.jivesoftware.smack.SmackFuture; 024import org.jivesoftware.smack.c2s.internal.ModularXmppClientToServerConnectionInternal; 025 026public abstract class XmppClientToServerTransport { 027 028 protected final ModularXmppClientToServerConnectionInternal connectionInternal; 029 030 protected XmppClientToServerTransport(ModularXmppClientToServerConnectionInternal connectionInternal) { 031 this.connectionInternal = connectionInternal; 032 } 033 034 protected abstract void resetDiscoveredConnectionEndpoints(); 035 036 protected abstract List<SmackFuture<LookupConnectionEndpointsResult, Exception>> lookupConnectionEndpoints(); 037 038 protected abstract void loadConnectionEndpoints(LookupConnectionEndpointsSuccess lookupConnectionEndpointsSuccess); 039 040 public abstract boolean hasUseableConnectionEndpoints(); 041 042 /** 043 * Notify the transport that new outgoing data is available. Usually this method does not need to be called 044 * explicitly, only if the filters are modified so that they potentially produced new data. 045 */ 046 protected abstract void afterFiltersClosed(); 047 048 /** 049 * Called by the CloseConnection state. 050 */ 051 protected abstract void disconnect(); 052 053 protected abstract void notifyAboutNewOutgoingElements(); 054 055 public abstract SSLSession getSslSession(); 056 057 public boolean isTransportSecured() { 058 return getSslSession() != null; 059 } 060 061 public abstract StreamOpenAndCloseFactory getStreamOpenAndCloseFactory(); 062 063 public abstract Stats getStats(); 064 065 public abstract static class Stats { 066 } 067 068 protected interface LookupConnectionEndpointsResult { 069 } 070 071 protected interface LookupConnectionEndpointsSuccess extends LookupConnectionEndpointsResult { 072 } 073 074 public interface LookupConnectionEndpointsFailed extends LookupConnectionEndpointsResult { 075 // TODO: Add something like getExceptions() or getConnectionExceptions()? 076 } 077 078}