コード例 #1
0
    public void AskForGame()
    {
        Debug.Log("Looking for Game");
        Schema.LookingForGame lookingForGame = new Schema.LookingForGame()
        {
            Username = this.Id,
        };

        TCPConnection.SendMessage(Any.Pack(lookingForGame)).Wait();
    }
コード例 #2
0
    private void AskForGame(Schema.LookingForGame playerLookingForGame)
    {
        this.Game = Server.FindGame(this);

        Schema.JoinedGame joinedGame = new Schema.JoinedGame
        {
            Username = this.Username,
        };

        Console.WriteLine("Telling player they got a game");
        this.SendMessage(Any.Pack(joinedGame));

        Console.WriteLine("Telling player initial board state");
        this.SendMessage(Any.Pack(Game.Board.GetBoardState()));
    }
コード例 #3
0
ファイル: ClientTests.cs プロジェクト: tfritzy/Bestagon
    public void Client_HandlePlayerLookingForGame()
    {
        Client client = TestObjects.BuildClient();

        Schema.LookingForGame playerLookingForGame = client.BuildLookingForGame();
        client.ClientSendToServer(Any.Pack(playerLookingForGame));

        Assert.IsNotNull(client.Game);
        CollectionAssert.Contains(client.Game.Players, client);
        Game originalGame = client.Game;

        client.ClientSendToServer(Any.Pack(playerLookingForGame));
        Assert.AreEqual(1, client.Game.Players.Count);
        Assert.AreEqual(originalGame, client.Game);
        Assert.AreEqual(1, client.Server.OpenGames.Count);
    }
コード例 #4
0
ファイル: ClientTests.cs プロジェクト: tfritzy/Bestagon
    public void Client_ExtractDataFromConnection()
    {
        Client client = TestObjects.BuildClient();

        Schema.LookingForGame player = new Schema.LookingForGame()
        {
            Username = "******"
        };
        byte[] bytes = Any.Pack(player).ToByteArray();
        client.TCPConnection.ReceiveBuffer = bytes;
        Assert.AreEqual(Constants.DEFAULT_BUFFER_SIZE, client.TCPConnection.ReceiveBuffer.Length);

        client.TCPConnection.ExtractDataFromBuffer(bytes.Length);

        Schema.LookingForGame readJoinedGame = client.TCPConnection.ReceivedData.Message.Unpack <Schema.LookingForGame>();
        Assert.AreEqual(player, readJoinedGame);
    }