示例#1
0
        public void AddVote(T candidate, string votingPeer, long msgTime, int totalPeers)
        {
            UpdateAllStatus();
            VoteData vd;

            try {
                vd = _voteDict[candidate];
                if (vd.Status == VoteStatus.Voting)
                {
                    vd.AddVote(votingPeer, msgTime);
                    vd.UpdateStatus(SysMs);
                    _voteDict[candidate] = vd; // VoteData is a struct (value) so must be re-added
                    Logger.Debug($"Vote.Add: +1 for: {candidate.ToString()}, Votes: {vd.PeerIds.Count}");
                }
            } catch (KeyNotFoundException) {
                int majorityCnt = MajorityVotes(totalPeers);
                vd = new VoteData(majorityCnt, msgTime, SysMs + TimeoutMs, SysMs + CleanupMs);
                vd.PeerIds.Add(votingPeer);
                vd.UpdateStatus(SysMs);
                _voteDict[candidate] = vd;
                Logger.Debug($"Vote.Add: New: {candidate.ToString()}, Majority: {majorityCnt}");
            }
        }
示例#2
0
        public void OnCheckpointCommand(long seqNum, long timeStamp)
        {
            logger.Info($"OnCheckpointCommand() seqNum: {seqNum}, timestamp: {timeStamp}, Now: {FrameApianTime}");
            CoreData.UpdateCommandSequenceNumber(seqNum);
            string stateJson = CoreData.ApianSerialized(new BeamCoreState.SerialArgs(seqNum, FrameApianTime, timeStamp));

            logger.Debug($"**** Checkpoint:\n{stateJson}\n************\n");
            apian.SendCheckpointState(FrameApianTime, seqNum, stateJson);

            // BeamGameState newState =  BeamGameState.FromApianSerialized(GameData, seqNum,  timeStamp,  "blahblah", stateJson);
        }
        // Ground

        public void OnPlaceFreedEvt(object sender, BeamPlace p)
        {
            logger.Debug($"OnFreePlace({p.xIdx}, {p.zIdx})");
        }
示例#4
0
 // Ground
 public void OnSetupPlaceMarkerEvt(object sender, BeamPlace p)
 {
     logger.Debug($"OnSetupPlaceMarkerEvt({p.xIdx}, {p.zIdx})");
 }