Exemple #1
0
        public void Start()
        {
            Server = new Server(_address, _port, true);

            var dispacher = new PacketDispacher <PacketType>(Server);

            dispacher.RegisterHandler(PacketType.LOGIN, HandleLOGIN);

            Server.Start(25, _slots);
        }
Exemple #2
0
        public void Connect()
        {
            Client = new Client(true);
            var dispacher = new PacketDispacher <PacketType>(Client);

            dispacher.RegisterHandler(PacketType.WORLD, HandleWORLD);
            dispacher.RegisterHandler(PacketType.LEVEL, HandleLEVEL);
            dispacher.RegisterHandler(PacketType.CHUNK, HandleCHUNK);
            dispacher.RegisterHandler(PacketType.JOINT, HandleJOINT);
            dispacher.RegisterHandler(PacketType.TILE, HandleTILE);
            dispacher.RegisterHandler(PacketType.TILE_DATA, HandleTILEDATA);

            Client.Connect(_address, _port, 16);

            Client.Send(Packets.Login("testplayer", "{}"));

            new BufferReader(Client.Wait()).Ignore(sizeof(int)).ReadInteger(out var token);
            Logger.Log <GameState>($"Recived token {token} from server.");

            while (!_jointed)
            {
                ;
            }
        }