2017-03-01 19:09:48 -05:00
|
|
|
package com.github.steveice10.packetlib.test;
|
2013-11-29 17:34:06 -05:00
|
|
|
|
2017-03-01 19:09:48 -05:00
|
|
|
import com.github.steveice10.packetlib.Server;
|
2021-01-15 15:42:00 -05:00
|
|
|
import com.github.steveice10.packetlib.Session;
|
|
|
|
import com.github.steveice10.packetlib.tcp.TcpClientSession;
|
|
|
|
import com.github.steveice10.packetlib.tcp.TcpServer;
|
2013-12-14 19:41:25 -05:00
|
|
|
|
|
|
|
import javax.crypto.KeyGenerator;
|
|
|
|
import javax.crypto.SecretKey;
|
2014-03-01 19:47:03 -05:00
|
|
|
import java.security.NoSuchAlgorithmException;
|
2013-11-29 17:34:06 -05:00
|
|
|
|
|
|
|
public class PingServerTest {
|
2015-07-20 14:02:42 -04:00
|
|
|
public static void main(String[] args) {
|
2021-01-15 15:42:00 -05:00
|
|
|
SecretKey key;
|
2015-07-20 14:02:42 -04:00
|
|
|
try {
|
|
|
|
KeyGenerator gen = KeyGenerator.getInstance("AES");
|
|
|
|
gen.init(128);
|
|
|
|
key = gen.generateKey();
|
|
|
|
} catch(NoSuchAlgorithmException e) {
|
|
|
|
System.err.println("AES algorithm not supported, exiting...");
|
|
|
|
return;
|
|
|
|
}
|
2013-11-29 17:34:06 -05:00
|
|
|
|
2021-01-15 15:42:00 -05:00
|
|
|
Server server = new TcpServer("127.0.0.1", 25565, TestProtocol.class);
|
2015-07-20 14:02:42 -04:00
|
|
|
server.addListener(new ServerListener(key));
|
2015-08-21 22:15:36 -04:00
|
|
|
server.bind();
|
2013-12-14 19:41:25 -05:00
|
|
|
|
2021-01-15 15:42:00 -05:00
|
|
|
Session client = new TcpClientSession("127.0.0.1", 25565, new TestProtocol(key));
|
|
|
|
client.connect();
|
2015-07-20 14:02:42 -04:00
|
|
|
}
|
2013-11-29 17:34:06 -05:00
|
|
|
}
|