Skip to content

Instantly share code, notes, and snippets.

@SocraticPhoenix
Last active February 26, 2016 19:40
Show Gist options
  • Save SocraticPhoenix/75e815c1fbfe04256d8a to your computer and use it in GitHub Desktop.
Save SocraticPhoenix/75e815c1fbfe04256d8a to your computer and use it in GitHub Desktop.
package com.gmail.socraticphoenix.plasma;
import com.gmail.socraticphoenix.plasma.file.jlsc.JLSCException;
import com.gmail.socraticphoenix.plasma.math.IntRange;
import com.gmail.socraticphoenix.plasma.net.client.Client;
import com.gmail.socraticphoenix.plasma.net.client.event.ClientReceivedPacketEvent;
import com.gmail.socraticphoenix.plasma.net.packet.Packet;
import com.gmail.socraticphoenix.plasma.net.server.Server;
import com.gmail.socraticphoenix.plasma.net.server.event.ServerReceivedPacketEvent;
import com.gmail.socraticphoenix.plasma.reflection.event.EventListener;
import java.io.IOException;
import java.util.UUID;
import java.util.concurrent.TimeUnit;
public class Test {
public static void main(String[] args) throws InterruptedException, IOException, JLSCException {
Object listener = new Object() {
@EventListener
public void onServerReceive(ServerReceivedPacketEvent.Verified ev) {
System.out.println("Server received packet: " + ev.getPacket().getValue().getValue().get());
}
@EventListener
public void onClientReceive(ClientReceivedPacketEvent ev) {
System.out.println("Client received packet: " + ev.getPacket().getValue().getValue().get());
}
};
Server server = new Server(4321, "pass");
Client client = new Client(UUID.randomUUID(), "pass", 4321, "localhost");
server.getEventManager().registerListener(listener);
client.getEventManager().registerListener(listener);
server.start();
TimeUnit.MILLISECONDS.sleep(100);
client.start();
TimeUnit.MILLISECONDS.sleep(100);
server.getClientManager().queue(Packet.of(new IntRange(312, 421432)));
TimeUnit.MILLISECONDS.sleep(100);
server.close();
client.close();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment