public BlocksChangedMessage Flush(float elapsedTime, bool forced) { if (_blockPositions.Count == 0) { return(null); } cumulatedElapsedTime += elapsedTime; if (cumulatedElapsedTime > 0.032 || forced) { BlocksChangedMessage bufferedMessage = new BlocksChangedMessage() { BlockPositions = _blockPositions.ToArray(), BlockValues = _blockValues.ToArray(), Tags = _tags.ToArray(), }; _blockPositions.Clear(); _blockValues.Clear(); _tags.Clear(); cumulatedElapsedTime = 0; return(bufferedMessage); } return(null); }
protected void OnMessageBlockChange(BlocksChangedMessage ea) { if (MessageBlockChange != null && ea != null) { MessageBlockChange(this, new ProtocolMessageEventArgs <BlocksChangedMessage> { Message = ea }); } }
public void Add(BlocksChangedMessage msg) { _blockPositions.AddRange(msg.BlockPositions); _blockValues.AddRange(msg.BlockValues); if (msg.Tags != null) { _tags.AddRange(msg.Tags); } else { for (int i = 0; i < msg.BlockPositions.Length; i++) { _tags.Add(null); } } }