예제 #1
0
        private void BeginSend(ILetter letter)
        {
            _currentLetter = letter;
            byte[] serializedLetter = _letterSerializer.Serialize(letter);
            _sendEventArgs.SetBuffer(serializedLetter, 0, serializedLetter.Length);

            try {
                bool pending = _socket.SendAsync(_sendEventArgs);
                if (!pending)
                {
                    EndSend(_sendEventArgs);
                }
            } catch (Exception) {
                HandleSocketError(ShutdownReason.Socket);
            }
        }
예제 #2
0
        public Letter.Letter Build()
        {
            var letter = new Letter.Letter {
                Type = LetterType.Batch, Options = _batchOptions
            };

            int lettersInBatch = _letters.Count;

            letter.Parts = new byte[lettersInBatch][];
            for (int i = 0; i < lettersInBatch; i++)
            {
                letter.Parts[i] = _serializer.Serialize(_letters.Dequeue());
            }

            return(letter);
        }