Class WebsocketConnection.Builder<B extends WebsocketConnection.Builder<B>>
- Type Parameters:
B
- the type of the Builder that is returned
- All Implemented Interfaces:
BuilderInterface
- Enclosing class:
WebsocketConnection
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionbuild()
Finish building theWebsocketConnection
object.Emitted when the connection has completely closed.This signal will be emitted during an orderly close.onError
(WebsocketConnection.ErrorCallback handler) Emitted when an error occurred on the WebSocket.Emitted when we receive a message from the peer.onPong
(WebsocketConnection.PongCallback handler) Emitted when we receive a Pong frame (solicited or unsolicited) from the peer.setConnectionType
(WebsocketConnectionType connectionType) The type of connection (client/server).setExtensions
(MemorySegment extensions) List ofWebsocketExtension
objects that are active in the connection.setIoStream
(IOStream ioStream) The underlying IO stream the WebSocket is communicating over.setKeepaliveInterval
(int keepaliveInterval) Interval in seconds on when to send a ping message which will serve as a keepalive message.setKeepalivePongTimeout
(int keepalivePongTimeout) Timeout in seconds for when the absence of a pong from a keepalive ping is assumed to be caused by a faulty connection.setMaxIncomingPayloadSize
(long maxIncomingPayloadSize) The maximum payload size for incoming packets.The client's Origin.setProtocol
(String protocol) The chosen protocol, ornull
if a protocol was not agreed upon.The URI of the WebSocket.Methods inherited from class org.gnome.gobject.GObject.Builder
onNotify
Methods inherited from class io.github.jwharm.javagi.gobject.Builder
addBuilderProperty, connect, connect, connectSignals, getArena, getNames, getValues
-
Constructor Details
-
Builder
protected Builder()Default constructor for aBuilder
object.
-
-
Method Details
-
build
Finish building theWebsocketConnection
object. This will callGObject.withProperties(org.gnome.glib.Type, java.lang.String[], org.gnome.gobject.Value[])
to create a new GObject instance, which is then cast toWebsocketConnection
.- Overrides:
build
in classGObject.Builder<B extends WebsocketConnection.Builder<B>>
- Returns:
- a new instance of
WebsocketConnection
with the properties that were set in the Builder object. - Throws:
UnsupportedPlatformException
- when run on an unsupported platform
-
setConnectionType
The type of connection (client/server).- Parameters:
connectionType
- the value for theconnection-type
property- Returns:
- the
Builder
instance is returned, to allow method chaining
-
setExtensions
List ofWebsocketExtension
objects that are active in the connection.- Parameters:
extensions
- the value for theextensions
property- Returns:
- the
Builder
instance is returned, to allow method chaining
-
setIoStream
-
setKeepaliveInterval
Interval in seconds on when to send a ping message which will serve as a keepalive message.If set to 0 the keepalive message is disabled.
- Parameters:
keepaliveInterval
- the value for thekeepalive-interval
property- Returns:
- the
Builder
instance is returned, to allow method chaining
-
setKeepalivePongTimeout
Timeout in seconds for when the absence of a pong from a keepalive ping is assumed to be caused by a faulty connection. The WebSocket will be transitioned to a closed state when this happens.If set to 0 then the absence of pongs from keepalive pings is ignored.
- Parameters:
keepalivePongTimeout
- the value for thekeepalive-pong-timeout
property- Returns:
- the
Builder
instance is returned, to allow method chaining
-
setMaxIncomingPayloadSize
The maximum payload size for incoming packets.The protocol expects or 0 to not limit it.
- Parameters:
maxIncomingPayloadSize
- the value for themax-incoming-payload-size
property- Returns:
- the
Builder
instance is returned, to allow method chaining
-
setOrigin
-
setProtocol
-
setUri
-
onClosed
Emitted when the connection has completely closed.This happens either due to an orderly close from the peer, one initiated via
WebsocketConnection.close(short, java.lang.String)
or a fatal error condition that caused a close.This signal will be emitted once.
- Parameters:
handler
- the signal handler- Returns:
- the
Builder
instance is returned, to allow method chaining - See Also:
-
onClosing
This signal will be emitted during an orderly close.- Parameters:
handler
- the signal handler- Returns:
- the
Builder
instance is returned, to allow method chaining - See Also:
-
onError
Emitted when an error occurred on the WebSocket.This may be fired multiple times. Fatal errors will be followed by the
WebsocketConnection::closed
signal being emitted.- Parameters:
handler
- the signal handler- Returns:
- the
Builder
instance is returned, to allow method chaining - See Also:
-
onMessage
Emitted when we receive a message from the peer.As a convenience, the
message
data will always benull
-terminated, but the NUL byte will not be included in the length count.- Parameters:
handler
- the signal handler- Returns:
- the
Builder
instance is returned, to allow method chaining - See Also:
-
onPong
Emitted when we receive a Pong frame (solicited or unsolicited) from the peer.As a convenience, the
message
data will always benull
-terminated, but the NUL byte will not be included in the length count.- Parameters:
handler
- the signal handler- Returns:
- the
Builder
instance is returned, to allow method chaining - See Also:
-