class ServerWebSocket extends WebSocketBase
Represents a server side WebSocket.
Instances of this class are passed into a io.vertx.scala.core.http.HttpServer#websocketHandler or provided when a WebSocket handshake is manually io.vertx.scala.core.http.HttpServerRequest#upgradeed.
- Alphabetic
- By Inheritance
- ServerWebSocket
- WebSocketBase
- WriteStream
- ReadStream
- StreamBase
- AnyRef
- Any
- Hide All
- Show All
- Public
- All
Instance Constructors
- new ServerWebSocket(_asJava: AnyRef)
Value Members
-
final
def
!=(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
final
def
##(): Int
- Definition Classes
- AnyRef → Any
-
final
def
==(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
accept(): Unit
Accept the WebSocket and terminate the WebSocket handshake.
Accept the WebSocket and terminate the WebSocket handshake.
This method should be called from the websocket handler to explicitely accept the websocker and terminate the WebSocket handshake.
-
final
def
asInstanceOf[T0]: T0
- Definition Classes
- Any
-
def
asJava: AnyRef
- Definition Classes
- ServerWebSocket → WebSocketBase → WriteStream → ReadStream → StreamBase
-
def
binaryHandlerID(): String
When a
Websocket
is created it automatically registers an event handler with the event bus - the ID of that handler is given by this method.When a
Websocket
is created it automatically registers an event handler with the event bus - the ID of that handler is given by this method.Given this ID, a different event loop can send a binary frame to that event handler using the event bus and that buffer will be received by this instance in its own event loop and written to the underlying connection. This allows you to write data to other WebSockets which are owned by different event loops. * @return the binary handler id
- Definition Classes
- ServerWebSocket → WebSocketBase
-
def
binaryMessageHandler(handler: Handler[Buffer]): WebSocketBase
Set a binary message handler on the connection.
Set a binary message handler on the connection. This handler serves a similar purpose to io.vertx.scala.core.http.ServerWebSocket#handler except that if a message comes into the socket in multiple frames, the data from the frames will be aggregated into a single buffer before calling the handler (using io.vertx.scala.core.http.WebSocketFrame#isFinal to find the boundaries). * @param handler the handler
- returns
a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase
-
def
clone(): AnyRef
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
close(statusCode: Short, reason: Option[String]): Unit
- Definition Classes
- ServerWebSocket → WebSocketBase
-
def
close(statusCode: Short): Unit
- Definition Classes
- ServerWebSocket → WebSocketBase
-
def
close(): Unit
Close the WebSocket sending the default close frame.
Close the WebSocket sending the default close frame.
No more messages can be sent.
- Definition Classes
- ServerWebSocket → WebSocketBase
-
def
closeHandler(handler: Handler[Unit]): ServerWebSocket
Set a close handler.
Set a close handler. This will be called when the WebSocket is closed.
After this callback, no more messages are expected. * @param handler the handler
- returns
a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase
-
def
drainHandler(handler: Handler[Unit]): ServerWebSocket
Set a drain handler on the stream.
Set a drain handler on the stream. If the write queue is full, then the handler will be called when the write queue is ready to accept buffers again. See io.vertx.scala.core.streams.Pump for an example of this being used.
The stream implementation defines when the drain handler, for example it could be when the queue size has been reduced to
maxSize / 2
. * @param handler the handler- returns
a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase → WriteStream
-
def
end(): Unit
Calls io.vertx.scala.core.http.WebSocketBase#close
- Definition Classes
- ServerWebSocket → WebSocketBase → WriteStream
-
def
end(t: Buffer): Unit
Same as io.vertx.scala.core.http.WebSocketBase#end but writes some data to the stream before ending.
Same as io.vertx.scala.core.http.WebSocketBase#end but writes some data to the stream before ending.
- Definition Classes
- ServerWebSocket → WebSocketBase → WriteStream
-
def
endHandler(endHandler: Handler[Unit]): ServerWebSocket
Set an end handler.
Set an end handler. Once the stream has ended, and there is no more data to be read, this handler will be called. * @return a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase → ReadStream
-
final
def
eq(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
def
equals(arg0: Any): Boolean
- Definition Classes
- AnyRef → Any
-
def
exceptionHandler(handler: Handler[Throwable]): ServerWebSocket
Set an exception handler on the write stream.
Set an exception handler on the write stream. * @param handler the exception handler
- returns
a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase → WriteStream → ReadStream → StreamBase
-
def
fetch(amount: Long): ServerWebSocket
Fetch the specified
amount
of elements.Fetch the specified
amount
of elements. If theReadStream
has been paused, reading will recommence with the specifiedamount
of items, otherwise the specifiedamount
will be added to the current stream demand. * @return a reference to this, so the API can be used fluently- Definition Classes
- ServerWebSocket → WebSocketBase → ReadStream
-
def
finalize(): Unit
- Attributes
- protected[java.lang]
- Definition Classes
- AnyRef
- Annotations
- @throws( classOf[java.lang.Throwable] )
-
def
frameHandler(handler: Handler[WebSocketFrame]): ServerWebSocket
Set a frame handler on the connection.
Set a frame handler on the connection. This handler will be called when frames are read on the connection. * @param handler the handler
- returns
a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase
-
final
def
getClass(): Class[_]
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
handler(handler: Handler[Buffer]): ServerWebSocket
Set a data handler.
Set a data handler. As data is read, the handler will be called with the data. * @return a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase → ReadStream
-
def
hashCode(): Int
- Definition Classes
- AnyRef → Any
- Annotations
- @native()
-
def
headers(): MultiMap
- returns
the headers in the WebSocket handshake
-
final
def
isInstanceOf[T0]: Boolean
- Definition Classes
- Any
-
def
isSsl(): Boolean
- returns
true if this io.vertx.scala.core.http.HttpConnection is encrypted via SSL/TLS.
- Definition Classes
- ServerWebSocket → WebSocketBase
-
def
localAddress(): SocketAddress
- returns
the local address for this socket
- Definition Classes
- ServerWebSocket → WebSocketBase
-
final
def
ne(arg0: AnyRef): Boolean
- Definition Classes
- AnyRef
-
final
def
notify(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
final
def
notifyAll(): Unit
- Definition Classes
- AnyRef
- Annotations
- @native()
-
def
path(): String
- returns
the WebSocket handshake path.
-
def
pause(): ServerWebSocket
Pause the
ReadStream
, it sets the buffer infetch
mode and clears the actual demand.Pause the
ReadStream
, it sets the buffer infetch
mode and clears the actual demand.While it's paused, no data will be sent to the data
handler
. * @return a reference to this, so the API can be used fluently- Definition Classes
- ServerWebSocket → WebSocketBase → ReadStream
-
def
pongHandler(handler: Handler[Buffer]): WebSocketBase
Set a pong message handler on the connection.
Set a pong message handler on the connection. This handler will be invoked every time a pong message is received on the server, and can be used by both clients and servers since the RFC 6455 Sections 5.5.2 and 5.5.3 do not specify whether the client or server sends a ping.
Pong frames may be at most 125 bytes (octets).
There is no ping handler since pings should immediately be responded to with a pong with identical content
Pong frames may be received unsolicited. * @param handler the handler
- returns
a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase
-
def
query(): Option[String]
- returns
the WebSocket handshake query string.
-
def
reject(status: Int): Unit
Like io.vertx.scala.core.http.ServerWebSocket#reject but with a
status
. -
def
reject(): Unit
Reject the WebSocket.
Reject the WebSocket.
Calling this method from the websocket handler when it is first passed to you gives you the opportunity to reject the websocket, which will cause the websocket handshake to fail by returning a response code.
You might use this method, if for example you only want to accept WebSockets with a particular path.
-
def
remoteAddress(): SocketAddress
- returns
the remote address for this socket
- Definition Classes
- ServerWebSocket → WebSocketBase
-
def
resume(): ServerWebSocket
Resume reading, and sets the buffer in
flowing
mode.Resume reading, and sets the buffer in
flowing
mode.If the
ReadStream
has been paused, reading will recommence on it. * @return a reference to this, so the API can be used fluently- Definition Classes
- ServerWebSocket → WebSocketBase → ReadStream
-
def
setWriteQueueMaxSize(maxSize: Int): ServerWebSocket
Set the maximum size of the write queue to
maxSize
.Set the maximum size of the write queue to
maxSize
. You will still be able to write to the stream even if there is more thanmaxSize
items in the write queue. This is used as an indicator by classes such asPump
to provide flow control.The value is defined by the implementation of the stream, e.g in bytes for a io.vertx.scala.core.net.NetSocket, the number of io.vertx.scala.core.eventbus.Message for a io.vertx.scala.core.eventbus.MessageProducer, etc... * @param maxSize the max size of the write stream
- returns
a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase → WriteStream
-
def
subProtocol(): String
Returns the websocket sub protocol selected by the websocket handshake.
Returns the websocket sub protocol selected by the websocket handshake.
On the server, the value will be
null
when the handler receives the websocket callback as the handshake will not be completed yet.- Definition Classes
- ServerWebSocket → WebSocketBase
-
final
def
synchronized[T0](arg0: ⇒ T0): T0
- Definition Classes
- AnyRef
-
def
textHandlerID(): String
When a
Websocket
is created it automatically registers an event handler with the eventbus, the ID of that handler is given bytextHandlerID
.When a
Websocket
is created it automatically registers an event handler with the eventbus, the ID of that handler is given bytextHandlerID
.Given this ID, a different event loop can send a text frame to that event handler using the event bus and that buffer will be received by this instance in its own event loop and written to the underlying connection. This allows you to write data to other WebSockets which are owned by different event loops.
- Definition Classes
- ServerWebSocket → WebSocketBase
-
def
textMessageHandler(handler: Handler[String]): WebSocketBase
Set a text message handler on the connection.
Set a text message handler on the connection. This handler will be called similar to the , but the buffer will be converted to a String first * @param handler the handler
- returns
a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase
-
def
toString(): String
- Definition Classes
- AnyRef → Any
- def uri(): String
-
final
def
wait(): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long, arg1: Int): Unit
- Definition Classes
- AnyRef
- Annotations
- @throws( ... )
-
final
def
wait(arg0: Long): Unit
- Definition Classes
- AnyRef
- Annotations
- @native() @throws( ... )
-
def
write(data: Buffer): ServerWebSocket
Write some data to the stream.
Write some data to the stream. The data is put on an internal write queue, and the write actually happens asynchronously. To avoid running out of memory by putting too much on the write queue, check the io.vertx.scala.core.streams.WriteStream#writeQueueFull method before writing. This is done automatically if using a io.vertx.scala.core.streams.Pump. * @param data the data to write
- returns
a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase → WriteStream
-
def
writeBinaryMessage(data: Buffer): ServerWebSocket
Writes a (potentially large) piece of binary data to the connection.
Writes a (potentially large) piece of binary data to the connection. This data might be written as multiple frames if it exceeds the maximum WebSocket frame size. * @param data the data to write
- returns
a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase
-
def
writeFinalBinaryFrame(data: Buffer): ServerWebSocket
Write a final WebSocket binary frame to the connection * @param data The data to write
Write a final WebSocket binary frame to the connection * @param data The data to write
- returns
a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase
-
def
writeFinalTextFrame(text: String): ServerWebSocket
Write a final WebSocket text frame to the connection * @param text The text to write
Write a final WebSocket text frame to the connection * @param text The text to write
- returns
a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase
-
def
writeFrame(frame: WebSocketFrame): ServerWebSocket
Write a WebSocket frame to the connection * @param frame the frame to write
Write a WebSocket frame to the connection * @param frame the frame to write
- returns
a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase
-
def
writePing(data: Buffer): WebSocketBase
Writes a ping to the connection.
Writes a ping to the connection. This will be written in a single frame. Ping frames may be at most 125 bytes (octets).
This method should not be used to write application data and should only be used for implementing a keep alive or to ensure the client is still responsive, see RFC 6455 Section 5.5.2.
There is no pingHandler because RFC 6455 section 5.5.2 clearly states that the only response to a ping is a pong with identical contents. * @param data the data to write, may be at most 125 bytes
- returns
a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase
-
def
writePong(data: Buffer): WebSocketBase
Writes a pong to the connection.
Writes a pong to the connection. This will be written in a single frame. Pong frames may be at most 125 bytes (octets).
This method should not be used to write application data and should only be used for implementing a keep alive or to ensure the client is still responsive, see RFC 6455 Section 5.5.2.
There is no need to manually write a Pong, as the server and client both handle responding to a ping with a pong automatically and this is exposed to users.RFC 6455 Section 5.5.3 states that pongs may be sent unsolicited in order to implement a one way heartbeat. * @param data the data to write, may be at most 125 bytes
- returns
a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase
-
def
writeQueueFull(): Boolean
This will return
true
if there are more bytes in the write queue than the value set using io.vertx.scala.core.http.ServerWebSocket#setWriteQueueMaxSize * @return true if write queue is fullThis will return
true
if there are more bytes in the write queue than the value set using io.vertx.scala.core.http.ServerWebSocket#setWriteQueueMaxSize * @return true if write queue is full- Definition Classes
- ServerWebSocket → WebSocketBase → WriteStream
-
def
writeTextMessage(text: String): WebSocketBase
Writes a (potentially large) piece of text data to the connection.
Writes a (potentially large) piece of text data to the connection. This data might be written as multiple frames if it exceeds the maximum WebSocket frame size. * @param text the data to write
- returns
a reference to this, so the API can be used fluently
- Definition Classes
- ServerWebSocket → WebSocketBase