1 /*
2 * Copyright (c) 2002-2025 Gargoyle Software Inc.
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 * https://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 package org.htmlunit.websocket;
16
17 import java.io.IOException;
18 import java.net.URI;
19
20 /**
21 * Helper to have no direct dependency to the WebSockt client
22 * implementation used by HtmlUnit.
23 *
24 * @author Ronald Brill
25 */
26 public interface WebSocketAdapter {
27
28 /**
29 * Starts the client.
30 *
31 * @throws Exception in case of error
32 */
33 void start() throws Exception;
34
35 /**
36 * Connects to the given {@link URI}.
37 *
38 * @param url the target url
39 * @throws Exception in case of error
40 */
41 void connect(URI url) throws Exception;
42
43 /**
44 * Sends the provided content.
45 *
46 * @param content the content to be sent
47 * @throws IOException in case of error
48 */
49 void send(Object content) throws IOException;
50
51 /**
52 * Close the incomming session.
53 *
54 * @throws Exception in case of error
55 */
56 void closeIncommingSession() throws Exception;
57
58 /**
59 * Close the outgoing session.
60 *
61 * @throws Exception in case of error
62 */
63 void closeOutgoingSession() throws Exception;
64
65 /**
66 * Close the client.
67 *
68 * @throws Exception in case of error
69 */
70 void closeClient() throws Exception;
71 }