IEnumerator Start()
    {
        this.go = commandReceiver;
        this.allowedCommands = new Dictionary <string, Type>();

        Debug.Log("Connecting to server");
        // connect to server
        webSocket = new WebSocket(new Uri("ws://localhost:8000"));
        yield return(StartCoroutine(webSocket.Connect()));

        Debug.Log("CONNECTED TO WEBSOCKETS");
        var x = new PlayerWantsToJoinCommand()
        {
            gameId   = 4,
            name     = "afsd",
            playerId = Guid.Empty
        };

        this.sendToAll(x);
        // wait for messages
        while (true)
        {
            // read message
            string message = webSocket.RecvString();
            // check if message is not empty
            if (message != null)
            {
                this.recv(message);
            }
            // Debug.Log("RECEIVED FROM WEBSOCKETS: " + reply);
            // if connection error, break the loop
            if (webSocket.error != null)
            {
                Debug.LogError("Error: " + webSocket.error);
                break;
            }

            yield return(0);
        }
        // if error, close connection
        webSocket.Close();
    }
 public MultiplayerServer(IMultiplayerGameObject go, Dictionary <string, Type> allowedCommands)
 {
     this.go = go;
     this.allowedCommands = allowedCommands;
 }