public interface Vertx
You should normally only use a single instance of this class throughout your application. If you are running in the Vert.x container an instance will be provided to you.
If you are using Vert.x embedded, you can create an instance using one of the static VertxFactory.newVertx
methods.
This class acts as a factory for TCP/SSL and HTTP/HTTPS servers and clients, SockJS servers, and provides an instance of the event bus, file system and shared data classes, as well as methods for setting and cancelling timers.
Instances of this class are thread-safe.
Modifier and Type | Method and Description |
---|---|
boolean |
cancelTimer(long id)
Cancel the timer with the specified
id . |
DatagramSocket |
createDatagramSocket(InternetProtocolFamily family)
Create a new
DatagramSocket . |
DnsClient |
createDnsClient(java.net.InetSocketAddress... dnsServers)
Return the
DnsClient |
HttpClient |
createHttpClient()
Create a HTTP/HTTPS client
|
HttpServer |
createHttpServer()
Create an HTTP/HTTPS server
|
NetClient |
createNetClient()
Create a TCP/SSL client
|
NetServer |
createNetServer()
Create a TCP/SSL server
|
SockJSServer |
createSockJSServer(HttpServer httpServer)
Create a SockJS server that wraps an HTTP server
|
Context |
currentContext() |
EventBus |
eventBus()
The event bus
|
FileSystem |
fileSystem()
The File system object
|
boolean |
isEventLoop()
Is the current thread an event loop thread?
|
boolean |
isWorker()
Is the current thread an worker thread?
|
void |
runOnContext(Handler<java.lang.Void> action)
Put the handler on the event queue for the current loop (or worker context) so it will be run asynchronously ASAP after this event has
been processed
|
long |
setPeriodic(long delay,
Handler<java.lang.Long> handler)
Set a periodic timer to fire every
delay milliseconds, at which point handler will be called with
the id of the timer. |
long |
setTimer(long delay,
Handler<java.lang.Long> handler)
Set a one-shot timer to fire after
delay milliseconds, at which point handler will be called with
the id of the timer. |
SharedData |
sharedData()
The shared data object
|
void |
stop()
Stop the eventbus and any resource managed by the eventbus.
|
NetServer createNetServer()
NetClient createNetClient()
HttpServer createHttpServer()
HttpClient createHttpClient()
DatagramSocket createDatagramSocket(InternetProtocolFamily family)
DatagramSocket
.family
- use InternetProtocolFamily
to use for multicast. If null
is used it's up to the
operation system to detect it's default.DatagramSocket
.SockJSServer createSockJSServer(HttpServer httpServer)
FileSystem fileSystem()
EventBus eventBus()
DnsClient createDnsClient(java.net.InetSocketAddress... dnsServers)
DnsClient
SharedData sharedData()
long setTimer(long delay, Handler<java.lang.Long> handler)
delay
milliseconds, at which point handler
will be called with
the id of the timer.long setPeriodic(long delay, Handler<java.lang.Long> handler)
delay
milliseconds, at which point handler
will be called with
the id of the timer.boolean cancelTimer(long id)
id
. Returns
true if the timer was successfully cancelled, or
false
if the timer does not exist.Context currentContext()
void runOnContext(Handler<java.lang.Void> action)
boolean isEventLoop()
boolean isWorker()
void stop()