public class Controller extends Object
Modifier and Type | Field and Description |
---|---|
static Map<String,Class<BaseProtocol>> |
protocols |
Constructor and Description |
---|
Controller() |
Modifier and Type | Method and Description |
---|---|
static String |
getValueForKey(String str,
String key,
String delimitter)
Searches a key in a string and returns the value.
|
static boolean |
loadProtocol(String name)
Loads a protocol file from .
|
static void |
loadProtocols()
Loads all Protocols.
|
static int |
nthOccurrence(String str,
char c,
int n)
Returns the position of the nth occurence of a Char in a String.
|
static String |
send(byte[] sendData,
String IP,
int PORT,
String encoding)
Sends a package to the server (UDP) and returns the answer.
|
static String |
sendMulti(byte[] sendData,
String IP,
int PORT,
String encoding,
String endStr)
Sends a package to the server (UDP) and receives multiple packets.
|
static void |
start(int listIndex)
Connects to a server at a specified index.
|
public static Map<String,Class<BaseProtocol>> protocols
public static boolean loadProtocol(String name)
name
- The file name.public static void loadProtocols()
public static String send(byte[] sendData, String IP, int PORT, String encoding)
sendData
- The message that has to be sent, as byte array.IP
- Host IP/Address.PORT
- Blubbpublic static String sendMulti(byte[] sendData, String IP, int PORT, String encoding, String endStr)
sendData
- The message that has to be sent, as byte array.IP
- Host IP/Address.PORT
- Blubbpublic static void start(int listIndex)
listIndex
- The index the server has in Server.svArraypublic static String getValueForKey(String str, String key, String delimitter)
str
- The string that is searched in.key
- The key we want the value for.delimitter
- The delimitter of the key/value pairs.public static int nthOccurrence(String str, char c, int n)
str
- The string that is searched in.c
- The char to be searchedn
- The number of chars to skip.