Posted August 24, 201411 yr My Client > Server Request packets never seem to be being recieved on the server. I registered the message using NETWORK.registerMessage(MessageSyncEPP.Request.Handler.class, MessageSyncEPP.Request.class, 0, Side.SERVER); This is the Handler class: public static final class Handler implements IMessageHandler<Request, Response> { @Override public Response onMessage(Request message, MessageContext ctx) { System.out.println(String.format("REQUEST RECIEVED ON SIDE: %s", ForestMagic.instance.getSide())); LogHelper.packetRecieved(message); ExtendedPlayer properties = ExtendedPlayer.get(ctx.getServerHandler().playerEntity); Response response = new Response(); //ADD PROPERTIES HERE LogHelper.packetSent(response); return response; } } onMessage never seems to get called. I'm sending the packet like this MessageSyncEPP.Request request = new MessageSyncEPP.Request(); LogHelper.packetSent(request); NETWORK.sendToServer(request); The packetSent logging DOES happen, and it definitely happens from the client side. Is sendToServer not the proper way to send the message to the server? EDIT: Forgot to mention that my NETWORK variable is declared like this: public static final SimpleNetworkWrapper NETWORK = NetworkRegistry.INSTANCE.newSimpleChannel(Reference.MOD_ID.toLowerCase()); BEFORE ASKING FOR HELP READ THE EAQ! I'll help if I can. Apologies if I do something obviously stupid. If you don't know basic Java yet, go and follow these tutorials.
August 24, 201411 yr Author The request packet is empty from client > server and the response is sent back from server > client with appropriate details so that the client resyncs is information from the server. I'm sending the packet from the EntityConstructing event, I know that the event is called on both Server and Client. I check to make sure the entity is an instance of EntityPlayer, then check to make sure world.isRemote is true (So I'm only sending the request client side). The reason I'm using the Request/Response is because I'm going to need to use it in GUIs, and other client-only things where I can't send the 'response' directly. I was testing out to make sure it works first so I don't run into issues later. BEFORE ASKING FOR HELP READ THE EAQ! I'll help if I can. Apologies if I do something obviously stupid. If you don't know basic Java yet, go and follow these tutorials.
August 25, 201411 yr Author It is for this case, I can just use sendToPlayer with the 'Response' without the request. I was just testing the request to make sure it works and it seems it does not. Could it be because the request packet is empty? BEFORE ASKING FOR HELP READ THE EAQ! I'll help if I can. Apologies if I do something obviously stupid. If you don't know basic Java yet, go and follow these tutorials.
August 25, 201411 yr He's asking why do you need to send a packet from the client requesting information? What exactly are you trying to accomplish? Typically, the server already knows what's going on and can send information directly to the client when needed, such as when a GUI is opened, meaning you are making your code too complicated. What information do you need, where do you need it, and when do you need it? http://i.imgur.com/NdrFdld.png[/img]
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.