- Joined
- Aug 24, 2012
- Messages
- 603
- Reaction score
- 300
Azure Java by "Azure Group"
We've done most networking and packet handling, so we're close to the fun part!
Libraries, dude?!
Netty - Networking
Gradle - Building
HikariCP - Connection Pooling
Guice - Dependency Injection
Hibernate - ORM / Database Management
log4j - Logging
Trove - Collections/Storage Handling
Which release, bro?!
We're currently using the same release as the 2.0.100 build, so it's PRODUCTION-201506161211-776084490.
What I want to know is, crypto?!?!
Of course are we going to implement Habbo's crypto and in a proper way, so that we won't receive complaints about it being anywhere near to 'slow'.
Azure Java's Team
Why the change?
The previous Azure base was destroyed on several factors, and missing a lot of core code and functionality so we thought it would just be easy to create a new project in Java.
Snippets
Packet handling
Code:
public class MessageHandler {
private static HashMap<Short, Method> messages = new HashMap<Short, Method>();
private static final Logger logger = LogManager.getLogger(MessageHandler.class);
private static boolean initialized = false;
[USER=26105]POST[/USER]Construct
synchronized void init() {
if (initialized) {
return;
}
initialized = true;
logger.info("Scanning for MessageEvents");
String pkg = "org.azure.communication.messages";
Reflections reflections = new Reflections(new ConfigurationBuilder()
.setUrls(ClasspathHelper.forPackage(pkg))
.setScanners(new MethodAnnotationsScanner()));
Set<Method> methods = reflections.getMethodsAnnotatedWith(MessageEvent.class);
for (Method method : methods) {
MessageEvent event = method.getAnnotation(MessageEvent.class);
if (method.getReturnType().equals(Void.TYPE) && event != null && event.enabled()) {
if (messages.containsKey(event.messageId())) {
logger.error("Message ID collision: {}::{} with {}::{}",
messages.get(event.messageId()).getDeclaringClass().getSimpleName(),
messages.get(event.messageId()).getName(),
method.getDeclaringClass().getSimpleName(),
method.getName()
);
System.exit(1); // Fatal error
}
Parameter[] params = method.getParameters();
if (params.length == 2 && params[0].getType() == Session.class && params[1].getType() == ClientMessage.class) {
logger.info("Registered {}::{} to id {}",
method.getDeclaringClass().getSimpleName(),
method.getName(),
event.messageId()
);
messages.put(event.messageId(), method);
}
}
}
}
public static void invoke(Session session, ClientMessage message) {
if (session == null || message == null) return;
if (!messages.containsKey(message.opCode)) {
logger.info("Unknown message (id: " + message.opCode + " session: " + session.getId() + ") " + message.toString());
return;
}
logger.debug("Incoming message (id: " + message.opCode + " session: " + session.getId() + ") " + message.toString());
try {
messages.get(message.opCode).invoke(null, session, message);
} catch (IllegalAccessException e) {
logger.error("Error", e);
} catch (InvocationTargetException e) {
logger.error("Error", e);
}
}
}
Last edited: