public class HttpServerImpl extends Object implements HttpServer
| 构造器和说明 |
|---|
HttpServerImpl(ServerOptions serverOptions) |
HttpServerImpl(String name,
ServerOptions serverOptions) |
| 限定符和类型 | 方法和说明 |
|---|---|
SocketAddress |
address()
Returns the
SocketAddress that the server is listening on. |
void |
await()
Waits for this server to be closed.
|
void |
awaitUninterruptibly()
Waits for this server to be closed.
|
io.netty.channel.EventLoopGroup |
bossGroup()
Returns the boss
EventLoopGroup which is used to accepting new connections. |
void |
close()
Closes current server.
|
io.netty.util.concurrent.Future<Void> |
closeFuture()
Returns the
Future which is notified when server is closed(probably by calling HttpServer.close()). |
HttpServerImpl |
handle(Consumer<RequestHandle> h)
Sets the handler for handing requests received.
|
io.netty.channel.EventLoopGroup |
ioGroup()
Returns the io
EventLoopGroup which is used to handing I/O events. |
HttpServerImpl |
listen(int port)
Starts the server which is listening on the given
port. |
HttpServerImpl |
listen(SocketAddress address)
Starts the server which is listening on the given
address. |
HttpServerImpl |
listen(String host,
int port)
Starts the server which is listening on the given
host and port. |
Metrics |
metrics()
Returns the metrics of current server.
|
String |
name()
Returns the identity name of this server.
|
HttpServerImpl |
onClose(Runnable closure)
Adds a close hook which will be called when server is about to closing.
|
HttpServerImpl |
onConnected(Consumer<io.netty.channel.ChannelHandlerContext> h)
Sets the handler for listening connection connected.
|
HttpServerImpl |
onDisconnected(Consumer<io.netty.channel.Channel> h)
Sets the handler for listening connection disconnected.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitcreate, create, createpublic HttpServerImpl(ServerOptions serverOptions)
public HttpServerImpl(String name, ServerOptions serverOptions)
public HttpServerImpl handle(Consumer<RequestHandle> h)
HttpServerhandle 在接口中 HttpServerh - handlerpublic HttpServerImpl onConnected(Consumer<io.netty.channel.ChannelHandlerContext> h)
HttpServeronConnected 在接口中 HttpServerh - handlerpublic HttpServerImpl onDisconnected(Consumer<io.netty.channel.Channel> h)
HttpServeronDisconnected 在接口中 HttpServerh - handlerpublic HttpServerImpl onClose(Runnable closure)
HttpServeronClose 在接口中 HttpServerclosure - hookpublic HttpServerImpl listen(int port)
HttpServerport.listen 在接口中 HttpServerport - port to listen onpublic HttpServerImpl listen(String host, int port)
HttpServerhost and port.listen 在接口中 HttpServerhost - host to listen onport - port to listen onpublic HttpServerImpl listen(SocketAddress address)
HttpServeraddress.listen 在接口中 HttpServeraddress - address to listen onpublic String name()
HttpServer
!Note: this name would not be same with the name you passed in the HttpServer.create(String, ServerOptions)
for avoiding passing the same many a time
name 在接口中 HttpServerpublic void await()
throws InterruptedException
HttpServerawait 在接口中 HttpServerInterruptedExceptionpublic void awaitUninterruptibly()
HttpServerawaitUninterruptibly 在接口中 HttpServerpublic io.netty.util.concurrent.Future<Void> closeFuture()
HttpServerFuture which is notified when server is closed(probably by calling HttpServer.close()).closeFuture 在接口中 HttpServerpublic io.netty.channel.EventLoopGroup bossGroup()
HttpServerEventLoopGroup which is used to accepting new connections.bossGroup 在接口中 HttpServerEventLoopGroup or null if server is not running.public io.netty.channel.EventLoopGroup ioGroup()
HttpServerEventLoopGroup which is used to handing I/O events.ioGroup 在接口中 HttpServerEventLoopGroup or null if server is not running.public SocketAddress address()
HttpServerSocketAddress that the server is listening on.address 在接口中 HttpServerSocketAddress or null if server is not running.public Metrics metrics()
HttpServer
This method will never return null, but may return an Metrics which does not have any metrics.
metrics 在接口中 HttpServerpublic void close()
HttpServerclose 在接口中 HttpServerCopyright © 2020. All rights reserved.