internal RpcServerSession( Dispatcher dispatcher, ServerTransport transport, ServerSessionContext context ) { if ( dispatcher == null ) { throw new ArgumentNullException( "dispatcher" ); } if ( transport == null ) { throw new ArgumentNullException( "transport" ); } if ( !context.IsValid ) { throw new ArgumentException( "'context' is invalid.", "context" ); } Contract.EndContractBlock(); this._dispatcher = dispatcher; this._transport = transport; this._sessionContext = context; }
protected RpcServerSession CreateSession( EndPoint remoteEndPoint, ServerSessionContext context ) { if ( remoteEndPoint == null ) { throw new ArgumentNullException( "remoteEndPoint" ); } if ( !context.IsValid ) { throw new ArgumentException( "'context' is invalid.", "context" ); } Contract.EndContractBlock(); var newSesson = this._sessionFactory( context ); var result = this._sessionPool.AddOrUpdate( remoteEndPoint, newSesson, ( oldKey, oldValue ) => oldValue ); //if ( Object.ReferenceEquals( newSesson, result ) ) //{ // newSesson.Start(); //} //else //{ // newSesson.Dispose(); //} return result; }
public void SendAsync( ServerSessionContext context, IEnumerable<byte> response ) { Contract.Assert( context.Underlying.SendingContext != null ); // TODO: streaming. var buffer = response.ToArray(); context.Underlying.SendingContext.SetBuffer( buffer, 0, buffer.Length ); if ( !context.Underlying.ConnectSocket.SendAsync( context.Underlying.SendingContext ) ) { // Just check error. this.HandleError( context.Underlying.LastOperation, context.Underlying.SocketError ); } }