Top Description Fields Constructors Methods
com.sun.star.lib.connections.websocket

public Class WebsocketConnection

extends WebSocketClient
implements com.sun.star.connection.XConnection, com.sun.star.connection.XConnectionBroadcaster
Class Inheritance
Imports
java.io.BufferedInputStream, .ByteArrayOutputStream, .IOException, .InputStream, .OutputStream, .PipedInputStream, .PipedOutputStream, java.net.ProtocolException, .Socket, .URI, .URISyntaxException, java.nio.charset.StandardCharsets, java.nio.ByteBuffer, java.util.ArrayList, .Arrays, javax.swing.text.html.HTMLDocument.Iterator, com.sun.star.connection.XConnection, com.sun.star.connection.XConnectionBroadcaster, com.sun.star.io.XStreamListener, org.java_websocket.client.WebSocketClient, org.java_websocket.handshake.ServerHandshake

The WebsocketConnection implements the XConnection interface and is uses by the WebsocketConnector.

This class is not part of the provided api.

See Also
com.sun.star.lib.connections.socket.socketAcceptor, com.sun.star.lib.connections.socket.socketConnector, com.sun.star.connection.XConnection

Field Summary

Modifier and TypeField and Description
protected String
protected InputStream
protected OutputStream
protected ArrayList<com.sun.star.io.XStreamListener>
protected ByteArrayOutputStream
public static final boolean
DEBUG

When set to true, enables various debugging output.

pack-priv static final byte[]
Inherited from org.java_websocket.client.WebSocketClient:
uri

Constructor Summary

AccessConstructor and Description
public
WebsocketConnection(String
the description of the connection.
description
,
ConnectionDescriptor
the websocket ConnectionDescriptor containing information such as the websocket URL
desc
)

Constructs a new WebsocketConnection.

Method Summary

Modifier and TypeMethod and Description
public void
addStreamListener(com.sun.star.io.XStreamListener aListener)

public void
public void
flush()

Sends the data over the websocket to whatever is on the other side.

public String

Returns:

the description.
getDescription
()

Gives a description of the connection.

private void
private void
notifyListeners_error(com.sun.star.uno.Exception exception)

private void
public void
onClose(int code, String reason, boolean remote)

Implements abstract org.java_websocket.client.WebSocketClient.onClose.

Called after the websocket connection has been closed.

public void
onError(Exception ex)

Implements abstract org.java_websocket.client.WebSocketClient.onError.

Called when errors occurs.

public void
onMessage(String message)

Implements abstract org.java_websocket.client.WebSocketClient.onMessage.

Callback for string messages received from the remote host

public void
onMessage(ByteBuffer message)

Overrides org.java_websocket.client.WebSocketClient.onMessage.

Callback for binary messages received from the remote host

public void
onOpen(ServerHandshake handshakedata)

Implements abstract org.java_websocket.client.WebSocketClient.onOpen.

Called after an opening handshake has been performed and the given websocket is ready to be written on.

public int

Returns:

the number of bytes read.
read
(byte[][]
the outparameter, where the bytes have to be placed.
bytes
,
int
the number of bytes to read.
nBytesToRead
)

Read the required number of bytes.

public void
removeStreamListener(com.sun.star.io.XStreamListener aListener)

public void
write(byte[]
the bytes to write.
aData
)

Write bytes.

Inherited from org.java_websocket.client.WebSocketClient:
addHeaderclearHeaderscloseclosecloseBlockingcloseConnectionconnectconnectBlockingconnectBlockinggetAttachmentgetConnectiongetConnectionsgetDraftgetLocalSocketAddressgetLocalSocketAddressgetProtocolgetReadyStategetRemoteSocketAddressgetRemoteSocketAddressgetResourceDescriptorgetSocketgetSSLSessiongetURIhasBufferedDatahasSSLSupportisClosedisClosingisFlushAndCloseisOpenonCloseInitiatedonClosingonSetSSLParametersonWebsocketCloseonWebsocketCloseInitiatedonWebsocketClosingonWebsocketErroronWebsocketMessageonWebsocketMessageonWebsocketOpenonWriteDemandreconnectreconnectBlockingremoveHeaderrunsendsendsendsendFragmentedFramesendFramesendFramesendPingsetAttachmentsetDnsResolversetProxysetSocketsetSocketFactory

Field Detail

_descriptionback to summary
protected String _description
_inputStreamback to summary
protected InputStream _inputStream
_inputStreamWriterback to summary
protected OutputStream _inputStreamWriter
_listenersback to summary
protected ArrayList<com.sun.star.io.XStreamListener> _listeners
_outputStreamback to summary
protected ByteArrayOutputStream _outputStream
DEBUGback to summary
public static final boolean DEBUG

When set to true, enables various debugging output.

outgoingPrefixback to summary
pack-priv static final byte[] outgoingPrefix

Constructor Detail

WebsocketConnectionback to summary
public WebsocketConnection(String description, ConnectionDescriptor desc) throws IOException, URISyntaxException, InterruptedException

Constructs a new WebsocketConnection.

Parameters
description:String

the description of the connection.

desc:ConnectionDescriptor

the websocket ConnectionDescriptor containing information such as the websocket URL

Method Detail

addStreamListenerback to summary
public void addStreamListener(com.sun.star.io.XStreamListener aListener) throws com.sun.star.uno.RuntimeException
closeback to summary
public void close() throws com.sun.star.uno.RuntimeException

Overrides org.java_websocket.client.WebSocketClient.close.

Implements org.java_websocket.WebSocket.close.

Closes the connection.

See Also
com.sun.star.connection.XConnection#close
flushback to summary
public void flush() throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException

Sends the data over the websocket to whatever is on the other side. **NOTE**: unlike with genuine streams, without flushing the data is never sent

See Also
com.sun.star.connection.XConnection#flush
getDescriptionback to summary
public String getDescription() throws com.sun.star.uno.RuntimeException

Gives a description of the connection.

Returns:String

the description.

See Also
com.sun.star.connection.XConnection#getDescription
notifyListeners_closeback to summary
private void notifyListeners_close()
notifyListeners_errorback to summary
private void notifyListeners_error(com.sun.star.uno.Exception exception)
notifyListeners_openback to summary
private void notifyListeners_open()
onCloseback to summary
public void onClose(int code, String reason, boolean remote)

Implements abstract org.java_websocket.client.WebSocketClient.onClose.

Doc from org.java_websocket.client.WebSocketClient.onClose.

Called after the websocket connection has been closed.

Annotations
@Override
onErrorback to summary
public void onError(Exception ex)

Implements abstract org.java_websocket.client.WebSocketClient.onError.

Doc from org.java_websocket.client.WebSocketClient.onError.

Called when errors occurs. If an error causes the websocket connection to fail onClose(int, String, boolean) will be called additionally.
This method will be called primarily because of IO or protocol errors.
If the given exception is an RuntimeException that probably means that you encountered a bug.

Annotations
@Override
onMessageback to summary
public void onMessage(String message)

Implements abstract org.java_websocket.client.WebSocketClient.onMessage.

Doc from org.java_websocket.client.WebSocketClient.onMessage.

Callback for string messages received from the remote host

Annotations
@Override
onMessageback to summary
public void onMessage(ByteBuffer message)

Overrides org.java_websocket.client.WebSocketClient.onMessage.

Doc from org.java_websocket.client.WebSocketClient.onMessage.

Callback for binary messages received from the remote host

Annotations
@Override
onOpenback to summary
public void onOpen(ServerHandshake handshakedata)

Implements abstract org.java_websocket.client.WebSocketClient.onOpen.

Doc from org.java_websocket.client.WebSocketClient.onOpen.

Called after an opening handshake has been performed and the given websocket is ready to be written on.

Annotations
@Override
readback to summary
public int read(byte[][] bytes, int nBytesToRead) throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException

Read the required number of bytes.

Parameters
bytes:byte[][]

the outparameter, where the bytes have to be placed.

nBytesToRead:int

the number of bytes to read.

Returns:int

the number of bytes read.

See Also
com.sun.star.connection.XConnection#read
removeStreamListenerback to summary
public void removeStreamListener(com.sun.star.io.XStreamListener aListener) throws com.sun.star.uno.RuntimeException
writeback to summary
public void write(byte[] aData) throws com.sun.star.io.IOException, com.sun.star.uno.RuntimeException

Write bytes.

Parameters
aData:byte[]

the bytes to write.

See Also
com.sun.star.connection.XConnection#write