Create ConnectionHandlerClass
Remove Codeduplication
This commit is contained in:
@@ -0,0 +1,47 @@
|
||||
package ch.zhaw.pm2.multichat.protocol;
|
||||
|
||||
public abstract class ConnectionHandler {
|
||||
private final NetworkHandler.NetworkConnection<String> connection;
|
||||
|
||||
// Data types used for the Chat Protocol
|
||||
private static final String DATA_TYPE_CONNECT = "CONNECT";
|
||||
private static final String DATA_TYPE_CONFIRM = "CONFIRM";
|
||||
private static final String DATA_TYPE_DISCONNECT = "DISCONNECT";
|
||||
private static final String DATA_TYPE_MESSAGE = "MESSAGE";
|
||||
private static final String DATA_TYPE_ERROR = "ERROR";
|
||||
|
||||
public static final String USER_NONE = "";
|
||||
public static final String USER_ALL = "*";
|
||||
|
||||
public enum State {
|
||||
NEW, CONFIRM_CONNECT, CONNECTED, CONFIRM_DISCONNECT, DISCONNECTED;
|
||||
}
|
||||
|
||||
public ConnectionHandler(NetworkHandler.NetworkConnection<String> connection) {
|
||||
this.connection = connection;
|
||||
}
|
||||
|
||||
public static String getDataTypeConnect() {
|
||||
return DATA_TYPE_CONNECT;
|
||||
}
|
||||
|
||||
public static String getDataTypeConfirm() {
|
||||
return DATA_TYPE_CONFIRM;
|
||||
}
|
||||
|
||||
public static String getDataTypeDisconnect() {
|
||||
return DATA_TYPE_DISCONNECT;
|
||||
}
|
||||
|
||||
public static String getDataTypeMessage() {
|
||||
return DATA_TYPE_MESSAGE;
|
||||
}
|
||||
|
||||
public static String getDataTypeError() {
|
||||
return DATA_TYPE_ERROR;
|
||||
}
|
||||
|
||||
public NetworkHandler.NetworkConnection<String> getConnection() {
|
||||
return connection;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user