/.metadata/.plugins/org.eclipse.core.resources/.history/69/10459600d7a2001e1d98c762f0e1eac2
https://bitbucket.org/fixpoint/connexion · #! · 53 lines · 44 code · 9 blank · 0 comment · 0 complexity · edffbbb99d1537dfeb9e2de2921775ad MD5 · raw file
- package info.reflectionsofmind.connexion.platform.control.cts.message;
-
- import info.reflectionsofmind.connexion.platform.control.cts.IClientToServerMessage;
- import info.reflectionsofmind.connexion.platform.control.cts.IClientToServerMessageDispatchTarget;
- import info.reflectionsofmind.connexion.platform.game.IAction;
- import info.reflectionsofmind.connexion.transport.ITransport.INode;
- import info.reflectionsofmind.connexion.util.convert.ClassBasedJsonCoder;
- import info.reflectionsofmind.connexion.util.convert.DecodingException;
- import info.reflectionsofmind.connexion.util.convert.EncodingException;
- import info.reflectionsofmind.connexion.util.convert.ICoder;
-
- import org.json.JSONObject;
-
- public class MsgActionRequest implements IClientToServerMessage
- {
- private final IAction action;
-
- public MsgActionRequest(final IAction action)
- {
- this.action = action;
- }
-
- public void dispatch(final IClientToServerMessageDispatchTarget target, final INode sender)
- {
- target.onClientAction(this, sender);
- }
-
- public IAction getAction()
- {
- return this.action;
- }
-
- public static final class Coder extends ClassBasedJsonCoder<MsgActionRequest>
- {
- @Override
- protected Class<? extends MsgActionRequest> getEncodableClass()
- {
- return MsgActionRequest.class;
- }
-
- @Override
- protected MsgActionRequest decodeJson(final JSONObject json) throws DecodingException
- {
- return new MsgActionRequest(this.actionCoder.decode(json.getJSONObject("action").toString()));
- }
-
- @Override
- protected JSONObject encodeJson(final MsgActionRequest object) throws EncodingException
- {
- return new JSONObject().put("action", this.actionCoder.encode(object.getAction()));
- }
- }
- }