public override TcpSendState Send(RCRunner runner, RCClosure closure, RCBlock message) { long cid = Interlocked.Increment(ref _cid); // Console.Out.WriteLine ("New Cid:{0}", cid); byte[] payload = _protocol.Serialize(this, message); TcpSendState correlation = new TcpSendState(_handle, cid, message); RCAsyncState state = new RCAsyncState(runner, closure, correlation); if (_outbox.Add(state)) { // Send will add the header to the payload. // This is something I will probably want to change by adding some kind of // serializer/formatter abstraction. int size = _buffer.PrepareSend(correlation.Id, payload); _socket.BeginSend( _buffer.SendBuffer, 0, size, SocketFlags.None, new AsyncCallback(SendCompleted), state); // Console.Out.WriteLine ("Client sending {0}", correlation.Id); } else { // Console.Out.WriteLine ("Another message has to go first"); } return(correlation); }
public override byte[] Serialize(RCValue message) { return(_protocol.Serialize(this, message)); }