728x90
public enum MessageType
{
Error(0), SPR(65537), SSR(65538), State(2), CmdAnswer(4), Command(5), CompoundIOConfig(102), CompoundIOValues(111), Event(21), List(13), ReturnState(14), Update(30), Stop(31), KeepAlive(1212752128), Register(1380271872), CompoundRequest(120), CompoundReply(121), CompoundEvent(122), Unknown(-1);
private int _id;
private static MessageType[] _types = values();
private MessageType(int id)
{
this._id = id;
}
public int getId()
{
return this._id;
}
public static MessageType fromId(int id)
{
for (MessageType type : _types) {
if (type._id == id) {
return type;
}
}
return Unknown;
}
}
switch (MessageType.fromId(message.getType()).ordinal())
{
case 1:
handleListMessage(message);
break;
728x90
728x90