package de.d3adspace.example;

import de.d3adspace.skylla.commons.config.SkyllaConfig;
import de.d3adspace.skylla.commons.config.SkyllaConfigBuilder;
import de.d3adspace.skylla.commons.protocol.Protocol;
import de.d3adspace.skylla.commons.protocol.handler.PacketHandler;
import de.d3adspace.skylla.commons.protocol.handler.PacketHandlerMethod;
import de.d3adspace.skylla.server.SkyllaServer;
import de.d3adspace.skylla.server.SkyllaServerFactory;

/**
 * @author Nathalie0hneHerz
 */
public class SkyllaSeverExample {
	
	public static void main(String[] args) {
		Protocol protocol = new Protocol();
		protocol.registerPacket(ChatPacket.class);
		protocol.registerListener(new ServerPacketHandlerExample());
		
		SkyllaConfig config = new SkyllaConfigBuilder()
			.setServerHost("localhost")
			.setServerPort(1337)
			.setProtocol(protocol)
			.createSkyllaConfig();
		
		SkyllaServer skyllaServer = SkyllaServerFactory.createSkyllaServer(config);
		skyllaServer.start();
	}
	
	public static class ServerPacketHandlerExample implements PacketHandler {
		
		@PacketHandlerMethod
		public void onPacketChat(ChatPacket chatPacket) {
			System.out.println("[Server] received: " + chatPacket);
		}
	}
}

@@ -1,8 +1,1120 @@
+/*%0A * Copyright (c) 2017 D3adspace%0A *%0A * Permission is hereby granted, free of charge, to any person obtaining a copy of%0A * this software and associated documentation files (the %22Software%22), to deal in%0A * the Software without restriction, including without limitation the rights to%0A * use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of%0A * the Software, and to permit persons to whom the Software is furnished to do so,%0A * subject to the following conditions:%0A *%0A * The above copyright notice and this permission notice shall be included in all%0A * copies or substantial portions of the Software.%0A *%0A * THE SOFTWARE IS PROVIDED %22AS IS%22, WITHOUT WARRANTY OF ANY KIND, EXPRESS OR%0A * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS%0A * FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR%0A * COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER%0A * IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN%0A * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.%0A */%0A%0A
 package 
@@ -1251,24 +1251,88 @@
 figBuilder;%0A
+import de.d3adspace.skylla.commons.connection.SkyllaConnection;%0A
 import de.d3
@@ -2275,16 +2275,51 @@
 ketChat(
+SkyllaConnection skyllaConnection, 
 ChatPack
@@ -2394,16 +2394,65 @@
 acket);%0A
+%09%09%09%0A%09%09%09skyllaConnection.sendPackets(chatPacket);%0A
 %09%09%7D%0A%09%7D%0A%7D

change example to fit the new method signature