package com.apixandru.rummikub.client.waiting;

import com.apixandru.games.rummikub.brotocol.PacketWriter;
import com.apixandru.games.rummikub.brotocol.connect.client.PacketStart;
import com.apixandru.games.rummikub.brotocol.util.Reference;
import com.apixandru.rummikub.waiting.WaitingRoomConfigurer;
import com.apixandru.rummikub.waiting.WaitingRoomListener;

/**
 * @author Alexandru-Constantin Bledea
 * @since Apr 17, 2016
 */
public class ClientWaitingRoomConfigurer implements WaitingRoomConfigurer {

    private final PacketWriter packetWriter;
    private final Reference<WaitingRoomListener> listenerReference;

    public ClientWaitingRoomConfigurer(final PacketWriter packetWriter, final Reference<WaitingRoomListener> listenerReference) {
        this.packetWriter = packetWriter;
        this.listenerReference = listenerReference;
    }

    @Override
    public void registerListener(final WaitingRoomListener listener) {
        listenerReference.set(listener);
    }

    @Override
    public void startGame() {
        packetWriter.writePacket(new PacketStart());
    }

}

@@ -186,38 +186,32 @@
 t com.apixandru.
-games.
 rummikub.brotoco
@@ -207,31 +207,34 @@
 kub.
-brotocol.util.Reference
+client.ClientPacketHandler
 ;%0Aim
@@ -566,56 +566,41 @@
 nal 
-Reference%3CWaitingRoomListener%3E listenerReference
+ClientPacketHandler packetHandler
 ;%0A%0A 
@@ -680,56 +680,41 @@
 nal 
-Reference%3CWaitingRoomListener%3E listenerReference
+ClientPacketHandler packetHandler
 ) %7B%0A
@@ -772,45 +772,37 @@
 his.
-listenerReference = listenerReference
+packetHandler = packetHandler
 ;%0A  
@@ -903,29 +903,44 @@
     
-listenerReference.set
+packetHandler.setWaitingRoomListener
 (lis

use the packet handler instead