static void Main(string[] args) { IChessboard board = ServiceProxy.Create <IChessboard>("3", new Uri("fabric:/MessyChessApplication/Chessboard")); board.PutAPieceAsync(new ChessPieceInfo { ActorId = "1", PieceType = ChessPieceType.King, Team = 1, X = 1, Y = 1 }).Wait(); }
static void TestMisc() { var proxy = ActorProxy.Create <IKing>(new ActorId("1"), "fabric:/MessyChessApplication", "King"); proxy.SetInfoAsync(new ChessPieceInfo { ActorId = "1", PieceType = ChessPieceType.King, Team = 1, X = 1, Y = 1 }).Wait(); var king = proxy.GetInfoAsync().Result; Console.WriteLine(king.PieceType); Console.ReadLine(); Random rand = new Random(); while (true) { int x = 0; int y = 0; while (x < 8 && y < 8 || x >= 16 && y < 8 || x < 8 && y >= 16 || x >= 16 && y >= 16) { x = rand.Next(0, 24); y = rand.Next(0, 24); } string partition = ((y / 4) * 6 + (x / 4) + 1).ToString(); IChessboard boardShard = ServiceProxy.Create <IChessboard>(new Uri("fabric:/MessyChessApplication/Chessboard"), new ServicePartitionKey(partition)); boardShard.PutAPieceAsync(new ChessPieceInfo { ActorId = "1", PieceType = ChessPieceType.King, Team = rand.Next(1, 5), X = x, Y = y }).Wait(); IChessboardObserver board = ServiceProxy.Create <IChessboardObserver>(new Uri("fabric:/MessyChessApplication/ChessboardObserver")); var boardInfo = board.GetBoard(new CancellationToken()).Result; PaintBoard(boardInfo); Thread.Sleep(10); } }