コード例 #1
0
        public override void SendPackage(byte[] bytes)
        {
            lock (this) {
                if (waiting.Keys.Count == 256)
                {
                    throw new ExecutionEngineException("This Strategy can´t wait for more messages");
                }

                while (waiting.ContainsKey(_messageIdCount))
                {
                    _messageIdCount = (byte)((_messageIdCount + 1) % 256);
                }

                var messages   = new[] { _messageIdCount, NORMAL_MESSAGE_BYTE };
                var newMessage = ArrayUtils.AddBytesToArray(bytes, messages);

                TimerCallback tc = (state) => ReSendPackage((byte)state);
                waiting.Add(_messageIdCount, new MessageState(new Timer(tc, _messageIdCount, 0, _timeout), newMessage));
                _messageIdCount++;
            }
        }