StreamManagementModuleDescriptor.java

  1. /**
  2.  *
  3.  * Copyright 2019-2020 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.sm;

  18. import java.util.HashSet;
  19. import java.util.Set;

  20. import org.jivesoftware.smack.c2s.ModularXmppClientToServerConnectionConfiguration;
  21. import org.jivesoftware.smack.c2s.ModularXmppClientToServerConnectionModuleDescriptor;
  22. import org.jivesoftware.smack.c2s.internal.ModularXmppClientToServerConnectionInternal;
  23. import org.jivesoftware.smack.fsm.StateDescriptor;
  24. import org.jivesoftware.smack.sm.StreamManagementModule.EnableStreamManagementStateDescriptor;
  25. import org.jivesoftware.smack.sm.StreamManagementModule.ResumeStreamStateDescriptor;

  26. public class StreamManagementModuleDescriptor extends ModularXmppClientToServerConnectionModuleDescriptor {

  27.     private static final StreamManagementModuleDescriptor INSTANCE = new StreamManagementModuleDescriptor();

  28.     @Override
  29.     protected Set<Class<? extends StateDescriptor>> getStateDescriptors() {
  30.         Set<Class<? extends StateDescriptor>> res = new HashSet<>();
  31.         res.add(EnableStreamManagementStateDescriptor.class);
  32.         res.add(ResumeStreamStateDescriptor.class);
  33.         return res;
  34.     }

  35.     @Override
  36.     protected StreamManagementModule constructXmppConnectionModule(
  37.                     ModularXmppClientToServerConnectionInternal connectionInternal) {
  38.         return new StreamManagementModule(this, connectionInternal);
  39.     }

  40.     public static class Builder extends ModularXmppClientToServerConnectionModuleDescriptor.Builder {

  41.         protected Builder(ModularXmppClientToServerConnectionConfiguration.Builder connectionConfigurationBuilder) {
  42.             super(connectionConfigurationBuilder);
  43.         }

  44.         @Override
  45.         protected StreamManagementModuleDescriptor build() {
  46.             return INSTANCE;
  47.         }
  48.     }
  49. }