Task IAgent.SetInfoAsync(ChessPieceInfo info) { ActorEventSource.Current.ActorMessage(this, "Setting current count of value to {0}", info); this.State.Info.CopyFrom(info); return(Task.FromResult(true)); }
public async Task PutAPieceAsync(ChessPieceInfo piece) { var myDictionary = await this.StateManager.GetOrAddAsync <IReliableDictionary <string, ChessPieceInfo> >(mDictionaryName); var key = piece.X + "-" + piece.Y; using (var tx = this.StateManager.CreateTransaction()) { var result = await myDictionary.TryGetValueAsync(tx, key); if (result.HasValue) { if (result.Value.ActorId == "") { await myDictionary.SetAsync(tx, key, piece); } else { //TODO: Take a piece } } else { await myDictionary.AddAsync(tx, key, piece); } await tx.CommitAsync(); } await NotifyObservers(new CancellationToken()); }
public async Task TakeAPieceAsync(ChessPieceInfo piece) { var myDictionary = await this.StateManager.GetOrAddAsync <IReliableDictionary <string, ChessPieceInfo> >(mDictionaryName); var key = piece.X + "-" + piece.Y; using (var tx = this.StateManager.CreateTransaction()) { var result = await myDictionary.TryGetValueAsync(tx, key); if (result.HasValue && result.Value.ActorId == piece.ActorId) { await myDictionary.SetAsync(tx, key, ChessPieceInfo.Empty); } await tx.CommitAsync(); } await NotifyObservers(); }
Uri GetActorUri(ChessPieceInfo piece) { throw new NotImplementedException(); }
Task IPlayer.SetChessPieceInfoAsync(ChessPieceInfo piece) { this.StateManager.SetStateAsync <ChessPieceInfo>("ChessPiece", piece); mPieceProxy = ActorProxy.Create <IChessPiece>(new ActorId(piece.ActorId), GetActorUri(piece)); return(Task.FromResult(true)); }
Task IAgent.SetInfoAsync(ChessPieceInfo info) { ActorEventSource.Current.ActorMessage(this, "Setting current count of value to {0}", info); return(this.StateManager.SetStateAsync <ChessPieceInfo>("Info", info)); }