kryonet hide methods from serialization

I have some packets that have helper methods for initalizing such as this

	public String reason = "No reason give. Please contact the development team if you see this message!";
	
	private String[] reasonList = 
								{"Invalid Username.", 
								 "Invalid Password.", 
								 "This account has been banned." ,
								 "The server is currently in maintenance mode."
								};
	
	public Packet4LoginFailed(int index){
		reason = reasonList[index];
	}

I have registered the classes in the right order in both the server and the client (the registration is done in a shared class). However it errors. If I removed the constructor the packet no longer errors. I have a feeling this is to do with how kryo serializes the class. Is there anyway I can hide the constructor from serialization. I’m presuming there is some kind of annotation, however I couldn’t find anything in the kryonet google project page.

edit
the constructor is just 1 example of when I’d like to hide a method Some of my packets have other helper methods to make sure I initialize it properly.

Kryo requires a no-arg constructor (there are ways around it but that is the simple answer).
https://code.google.com/p/libgdx/wiki/GettingHelp#Exceptions

Wrong link, Nate. Best thing I could find was this: https://code.google.com/p/kryo/wiki/V1Documentation#Custom_serializers

Nope, it was the right link. I wrote that wiki article and I’ve taken to just linking to it instead of spending time trying to help people help me help them. The OP posted he had a problem that “errors” but never posted the exception, so he gets the link. :slight_smile:

You linked the Kryo v1 docs. The OP is likely on v2.

Ah I thought you wanted to link to the ways around the no-arg constructor. My bad :stuck_out_tongue:

sorry I didn’t reply to this topic sooner. I didn’t think I needed to post the error as I knew it was definitely to do with how the class was being registered (as when I removed the helper methods the error disappeared).

anyway I’ve sorted the probem now by going the simple route and getting rid of the methods.

If you’ve ever done tech support, the first thing you do is disregard the self diagnosis of the person you are helping. :slight_smile:

yeah doesnt really help though if you know at least as much as the tech support

like when you call to report a problem and they tell you to check the cable… not that I call those kinds of numbers ;D

If you knew as much as you thought, you wouldn’t be calling the tech support. :slight_smile: