1 /* 2 * Licensed to the Apache Software Foundation (ASF) under one or more 3 * contributor license agreements. See the NOTICE file distributed with 4 * this work for additional information regarding copyright ownership. 5 * The ASF licenses this file to You under the Apache License, Version 2.0 6 * (the "License"); you may not use this file except in compliance with 7 * the License. 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 javax.websocket; 18 19 import java.io.IOException; 20 import java.net.URI; 21 import java.util.Set; 22 23 public interface WebSocketContainer { 24 25 /** 26 * Get the default timeout for sending a message asynchronously. 27 * @return The current default timeout in milliseconds. A non-positive value 28 * means an infinite timeout. 29 */ getDefaultAsyncSendTimeout()30 long getDefaultAsyncSendTimeout(); 31 32 /** 33 * Set the default timeout for sending a message asynchronously. 34 * @param timeout The new default timeout in milliseconds. A non-positive 35 * value means an infinite timeout. 36 */ setAsyncSendTimeout(long timeout)37 void setAsyncSendTimeout(long timeout); 38 connectToServer(Object endpoint, URI path)39 Session connectToServer(Object endpoint, URI path) 40 throws DeploymentException, IOException; 41 connectToServer(Class<?> annotatedEndpointClass, URI path)42 Session connectToServer(Class<?> annotatedEndpointClass, URI path) 43 throws DeploymentException, IOException; 44 45 /** 46 * Creates a new connection to the WebSocket. 47 * 48 * @param endpoint 49 * The endpoint instance that will handle responses from the 50 * server 51 * @param clientEndpointConfiguration 52 * Used to configure the new connection 53 * @param path 54 * The full URL of the WebSocket endpoint to connect to 55 * 56 * @return The WebSocket session for the connection 57 * 58 * @throws DeploymentException If the connection cannot be established 59 * @throws IOException If an I/O occurred while trying to establish the 60 * connection 61 */ connectToServer(Endpoint endpoint, ClientEndpointConfig clientEndpointConfiguration, URI path)62 Session connectToServer(Endpoint endpoint, 63 ClientEndpointConfig clientEndpointConfiguration, URI path) 64 throws DeploymentException, IOException; 65 66 /** 67 * Creates a new connection to the WebSocket. 68 * 69 * @param endpoint 70 * An instance of this class will be created to handle responses 71 * from the server 72 * @param clientEndpointConfiguration 73 * Used to configure the new connection 74 * @param path 75 * The full URL of the WebSocket endpoint to connect to 76 * 77 * @return The WebSocket session for the connection 78 * 79 * @throws DeploymentException If the connection cannot be established 80 * @throws IOException If an I/O occurred while trying to establish the 81 * connection 82 */ connectToServer(Class<? extends Endpoint> endpoint, ClientEndpointConfig clientEndpointConfiguration, URI path)83 Session connectToServer(Class<? extends Endpoint> endpoint, 84 ClientEndpointConfig clientEndpointConfiguration, URI path) 85 throws DeploymentException, IOException; 86 87 /** 88 * Get the current default session idle timeout. 89 * @return The current default session idle timeout in milliseconds. Zero or 90 * negative values indicate an infinite timeout. 91 */ getDefaultMaxSessionIdleTimeout()92 long getDefaultMaxSessionIdleTimeout(); 93 94 /** 95 * Set the default session idle timeout. 96 * @param timeout The new default session idle timeout in milliseconds. Zero 97 * or negative values indicate an infinite timeout. 98 */ setDefaultMaxSessionIdleTimeout(long timeout)99 void setDefaultMaxSessionIdleTimeout(long timeout); 100 101 /** 102 * Get the default maximum buffer size for binary messages. 103 * @return The current default maximum buffer size in bytes 104 */ getDefaultMaxBinaryMessageBufferSize()105 int getDefaultMaxBinaryMessageBufferSize(); 106 107 /** 108 * Set the default maximum buffer size for binary messages. 109 * @param max The new default maximum buffer size in bytes 110 */ setDefaultMaxBinaryMessageBufferSize(int max)111 void setDefaultMaxBinaryMessageBufferSize(int max); 112 113 /** 114 * Get the default maximum buffer size for text messages. 115 * @return The current default maximum buffer size in characters 116 */ getDefaultMaxTextMessageBufferSize()117 int getDefaultMaxTextMessageBufferSize(); 118 119 /** 120 * Set the default maximum buffer size for text messages. 121 * @param max The new default maximum buffer size in characters 122 */ setDefaultMaxTextMessageBufferSize(int max)123 void setDefaultMaxTextMessageBufferSize(int max); 124 125 /** 126 * Get the installed extensions. 127 * @return The set of extensions that are supported by this WebSocket 128 * implementation. 129 */ getInstalledExtensions()130 Set<Extension> getInstalledExtensions(); 131 } 132