void ISendAsync.SendMessage(Message message, CompletionQueue.DelegateCompletionCallback callback) { //todo, assert overlap depth = 1 if (null == callback) throw new ArgumentException(); this.callback = callback; byte[] buffer = message.SerializeBytes(); writer.Seek(0, SeekOrigin.Begin); writer.Write((Int32)buffer.Length); writer.Write(buffer); writer.Flush(); byte[] send_buffer = ms.ToArray(); socket.BeginSend(send_buffer, 0, (Int32)writer.BaseStream.Position, SocketFlags.None, SendCallback, socket); }
void ISendAsync.SendMessage(Message message, CompletionQueue.DelegateCompletionCallback callback) { //todo, assert overlap depth = 1 if (null == callback) throw new ArgumentException(); this.callback = callback; byte[] buffer = message.SerializeBytes(); writer.Seek(0, SeekOrigin.Begin); writer.Write((Int32)buffer.Length); writer.Write(buffer); writer.Flush(); eventArgs.SetBuffer(send_buffer, 0, (Int32)writer.BaseStream.Position); if (!socket.SendAsync(eventArgs)) eventArgs_Completed(socket, eventArgs); }