Jump to content

SimpleNetworkWrapper Problem


Fearitude

Recommended Posts

Im trying to use SimpleNetworkWrapper as it looks like the best way to do the new network stuff, but ive run into a problem.

Im fairly sure im using it correctly but get the following error when trying to register the messages.

 

java.lang.IllegalStateException: cannot determine the type of the type parameter 'REQ': class cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper
at io.netty.util.internal.TypeParameterMatcher.fail(TypeParameterMatcher.java:171)
at io.netty.util.internal.TypeParameterMatcher.find0(TypeParameterMatcher.java:165)
at io.netty.util.internal.TypeParameterMatcher.find(TypeParameterMatcher.java:93)
at io.netty.channel.SimpleChannelInboundHandler.<init>(SimpleChannelInboundHandler.java:60)
at io.netty.channel.SimpleChannelInboundHandler.<init>(SimpleChannelInboundHandler.java:50)
at cpw.mods.fml.common.network.simpleimpl.SimpleChannelHandlerWrapper.<init>(SimpleChannelHandlerWrapper.java:17)
at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.getHandlerWrapper(SimpleNetworkWrapper.java:85)
at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.addServerHandlerAfter(SimpleNetworkWrapper.java:73)
at cpw.mods.fml.common.network.simpleimpl.SimpleNetworkWrapper.registerMessage(SimpleNetworkWrapper.java:63)

 

Im creating the wrapper in the init method with the following code.

network = new SimpleNetworkWrapper("MyChannel");
network.registerMessage(PacketHandler.class, Request.class, 1, Side.SERVER);

 

And my handler and messages are as below.

public class PacketHandler implements IMessageHandler<Request, Response>
{
@Override
public Response onMessage(Request message, MessageContext ctx)
{
	...
}
}
public class Request implements IMessage
{
...
}
public class Response implements IMessage
{
...
}

 

Am i missing something?

 

Link to comment
Share on other sites

Yeah i found SimpleNetworkWrapper by just looking through the docs, and it seemed well, simple.

I guess i could rewrite it to use the method in that tutorial but it seems unnecessarily complex for me when i just want to send 1 packet to the server and get a response.

 

Hopefully someone else has used this and can suggest a solution, otherwise ill just have to rewrite it.

 

Link to comment
Share on other sites

Yeah well, the SimpleChannelHandlerWrapper(Class handler, Side side) is bugged, as it never calls super(Class inboundMessageType... ) to get the matcher to cache the class and message type. The default constructor for the superclass relies on the parameter matcher to find it in the cache (which it won't because it was never used before) and fails when it is not there.

 

This should be addressed in bugs & software support.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.