com.github.czyzby.websocket.WebSocketHandler Maven / Gradle / Ivy
package com.github.czyzby.websocket;
import com.badlogic.gdx.utils.ObjectMap;
import com.github.czyzby.websocket.data.WebSocketException;
/** This is the proposed implementation of a {@link WebSocketListener} when using communicating with the server using
* serialized objects rather than raw strings or bytes. Instead of forcing the user to determine packet type manually
* (with {@code instanceof} or class comparing), this listener allows to register {@link Handler handlers} to each
* packet type - when the selected type of packet is received, registered handler will be invoked. This allows to build
* applications using event-driven approach. Errors during packet handling are delegated to
* {@link #onError(WebSocket, Throwable)} method rather than rethrown.
*
* @author MJ
* @see #registerHandler(Class, Handler)
* @see Handler */
public class WebSocketHandler extends AbstractWebSocketListener {
/** Maps class of expected packets to their handlers. */
private final ObjectMap, Handler
© 2015 - 2025 Weber Informatics LLC | Privacy Policy