Class Connection
java.lang.Object
io.netty.channel.ChannelHandlerAdapter
io.netty.channel.ChannelInboundHandlerAdapter
io.netty.channel.SimpleChannelInboundHandler<com.google.gson.JsonElement>
net.minecraft.server.jsonrpc.Connection
- All Implemented Interfaces:
io.netty.channel.ChannelHandler, io.netty.channel.ChannelInboundHandler
public class Connection
extends io.netty.channel.SimpleChannelInboundHandler<com.google.gson.JsonElement>
-
Nested Class Summary
Nested classes/interfaces inherited from interface io.netty.channel.ChannelHandler
io.netty.channel.ChannelHandler.Sharable -
Field Summary
FieldsModifier and TypeFieldDescriptionprivate final io.netty.channel.Channelprivate final ClientInfoprivate static final AtomicIntegerprivate final JsonRpcLoggerprivate static final org.slf4j.Loggerprivate final ManagementServerprivate final MinecraftApiprivate final it.unimi.dsi.fastutil.ints.Int2ObjectMap<PendingRpcRequest<?>> private final AtomicInteger -
Constructor Summary
ConstructorsConstructorDescriptionConnection(io.netty.channel.Channel channel, ManagementServer managementServer, MinecraftApi minecraftApi, JsonRpcLogger jsonrpcLogger) -
Method Summary
Modifier and TypeMethodDescriptionvoidchannelActive(io.netty.channel.ChannelHandlerContext ctx) voidchannelInactive(io.netty.channel.ChannelHandlerContext ctx) protected voidchannelRead0(io.netty.channel.ChannelHandlerContext channelHandlerContext, com.google.gson.JsonElement jsonElement) @Nullable com.google.gson.JsonElementdispatchIncomingRequest(String method, @Nullable com.google.gson.JsonElement params) voidexceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) private com.google.gson.JsonArrayhandleBatchRequest(List<com.google.gson.JsonElement> batchRequests) private @Nullable com.google.gson.JsonObjecthandleError(@Nullable com.google.gson.JsonElement id, com.google.gson.JsonObject error) private @Nullable com.google.gson.JsonObjecthandleIncomingRequest(@Nullable com.google.gson.JsonElement id, String method, @Nullable com.google.gson.JsonElement params) (package private) @Nullable com.google.gson.JsonObjecthandleJsonObject(com.google.gson.JsonObject jsonObject) private voidhandleRequestResponse(int id, com.google.gson.JsonElement result) private static booleanisValidRequestId(com.google.gson.JsonElement id) private static booleanisValidResponseId(com.google.gson.JsonElement id) voidsendNotification(Holder.Reference<? extends OutgoingRpcMethod<Void, ?>> method) <Params> voidsendNotification(Holder.Reference<? extends OutgoingRpcMethod<Params, ?>> method, Params params) <Result> CompletableFuture<Result> sendRequest(Holder.Reference<? extends OutgoingRpcMethod<Void, Result>> method) private <Params,Result>
@Nullable CompletableFuture<Result> sendRequest(Holder.Reference<? extends OutgoingRpcMethod<Params, ? extends Result>> method, @Nullable Params params, boolean expectReply) <Params,Result>
CompletableFuture<Result> sendRequest(Holder.Reference<? extends OutgoingRpcMethod<Params, Result>> method, Params params) voidtick()Methods inherited from class io.netty.channel.SimpleChannelInboundHandler
acceptInboundMessage, channelReadMethods inherited from class io.netty.channel.ChannelInboundHandlerAdapter
channelReadComplete, channelRegistered, channelUnregistered, channelWritabilityChanged, userEventTriggeredMethods inherited from class io.netty.channel.ChannelHandlerAdapter
ensureNotSharable, handlerAdded, handlerRemoved, isSharableMethods inherited from class Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface io.netty.channel.ChannelHandler
handlerAdded, handlerRemoved
-
Field Details
-
LOGGER
private static final org.slf4j.Logger LOGGER -
CONNECTION_ID_COUNTER
-
jsonRpcLogger
-
clientInfo
-
managementServer
-
channel
private final io.netty.channel.Channel channel -
minecraftApi
-
transactionId
-
pendingRequests
-
-
Constructor Details
-
Connection
public Connection(io.netty.channel.Channel channel, ManagementServer managementServer, MinecraftApi minecraftApi, JsonRpcLogger jsonrpcLogger)
-
-
Method Details
-
tick
public void tick() -
channelActive
-
channelInactive
-
exceptionCaught
public void exceptionCaught(io.netty.channel.ChannelHandlerContext ctx, Throwable cause) throws Exception - Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelHandler- Specified by:
exceptionCaughtin interfaceio.netty.channel.ChannelInboundHandler- Overrides:
exceptionCaughtin classio.netty.channel.ChannelInboundHandlerAdapter- Throws:
Exception
-
channelRead0
protected void channelRead0(io.netty.channel.ChannelHandlerContext channelHandlerContext, com.google.gson.JsonElement jsonElement) - Specified by:
channelRead0in classio.netty.channel.SimpleChannelInboundHandler<com.google.gson.JsonElement>
-
handleBatchRequest
private com.google.gson.JsonArray handleBatchRequest(List<com.google.gson.JsonElement> batchRequests) -
sendNotification
-
sendNotification
public <Params> void sendNotification(Holder.Reference<? extends OutgoingRpcMethod<Params, ?>> method, Params params) -
sendRequest
public <Result> CompletableFuture<Result> sendRequest(Holder.Reference<? extends OutgoingRpcMethod<Void, Result>> method) -
sendRequest
public <Params,Result> CompletableFuture<Result> sendRequest(Holder.Reference<? extends OutgoingRpcMethod<Params, Result>> method, Params params) -
sendRequest
@Contract("_,_,false->null;_,_,true->!null") private <Params,Result> @Nullable CompletableFuture<Result> sendRequest(Holder.Reference<? extends OutgoingRpcMethod<Params, ? extends Result>> method, @Nullable Params params, boolean expectReply) -
handleJsonObject
@Nullable com.google.gson.JsonObject handleJsonObject(com.google.gson.JsonObject jsonObject) -
isValidRequestId
private static boolean isValidRequestId(com.google.gson.JsonElement id) -
isValidResponseId
private static boolean isValidResponseId(com.google.gson.JsonElement id) -
handleIncomingRequest
private @Nullable com.google.gson.JsonObject handleIncomingRequest(@Nullable com.google.gson.JsonElement id, String method, @Nullable com.google.gson.JsonElement params) -
dispatchIncomingRequest
public @Nullable com.google.gson.JsonElement dispatchIncomingRequest(String method, @Nullable com.google.gson.JsonElement params) -
handleRequestResponse
private void handleRequestResponse(int id, com.google.gson.JsonElement result) -
handleError
private @Nullable com.google.gson.JsonObject handleError(@Nullable com.google.gson.JsonElement id, com.google.gson.JsonObject error)
-