This repository has been archived by the owner on May 7, 2020. It is now read-only.
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added WebSocketFactory interface and service (#6258)
* added WebSocketFactory interface and service Also-by: Markus Rathgeb <maggu2810@gmail.com> Signed-off-by: Kai Kreuzer <kai@openhab.org>
- Loading branch information
1 parent
029d7d9
commit 19313b3
Showing
7 changed files
with
205 additions
and
57 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
49 changes: 49 additions & 0 deletions
49
...se.smarthome.io.net/src/main/java/org/eclipse/smarthome/io/net/http/WebSocketFactory.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
/** | ||
* Copyright (c) 2014,2018 Contributors to the Eclipse Foundation | ||
* | ||
* See the NOTICE file(s) distributed with this work for additional | ||
* information regarding copyright ownership. | ||
* | ||
* This program and the accompanying materials are made available under the | ||
* terms of the Eclipse Public License 2.0 which is available at | ||
* http://www.eclipse.org/legal/epl-2.0 | ||
* | ||
* SPDX-License-Identifier: EPL-2.0 | ||
*/ | ||
package org.eclipse.smarthome.io.net.http; | ||
|
||
import org.eclipse.jdt.annotation.NonNullByDefault; | ||
import org.eclipse.jetty.websocket.client.WebSocketClient; | ||
|
||
/** | ||
* Factory class to create Jetty web socket clients | ||
* | ||
* @author Kai Kreuzer - Initial contribution | ||
*/ | ||
@NonNullByDefault | ||
public interface WebSocketFactory { | ||
|
||
/** | ||
* Creates a new Jetty web socket client. | ||
* The returned client is not started yet. You have to start it yourself before using. | ||
* Don't forget to stop a started client again after its usage. | ||
* The client lifecycle should be the same as for your service. | ||
* DO NOT CREATE NEW CLIENTS FOR EACH REQUEST! | ||
* | ||
* @param consumerName the for identifying the consumer in the Jetty thread pool. | ||
* Must be between 4 and 20 characters long and must contain only the following characters [a-zA-Z0-9-_] | ||
* @param endpoint the desired endpoint, protocol and host are sufficient | ||
* @return the Jetty client | ||
* @throws NullPointerException if {@code endpoint} or {@code consumerName} is {@code null} | ||
* @throws IllegalArgumentException if {@code consumerName} is invalid | ||
*/ | ||
WebSocketClient createWebSocketClient(String consumerName, String endpoint); | ||
|
||
/** | ||
* Returns a shared Jetty web socket client. You must not call any setter methods or {@code stop()} on it. | ||
* The returned client is already started. | ||
* | ||
* @return a shared Jetty web socket client | ||
*/ | ||
WebSocketClient getCommonWebSocketClient(); | ||
} |
Oops, something went wrong.