本文整理了Java中org.simpleframework.http.Request.getChannel
方法的一些代码示例,展示了Request.getChannel
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Request.getChannel
方法的具体详情如下:
包路径:org.simpleframework.http.Request
类名称:Request
方法名:getChannel
[英]This provides the underlying channel for the request. It contains the TCP socket channel and various other low level components. Typically this will only ever be needed when there is a need to switch protocols.
[中]这为请求提供了底层通道。它包含TCP套接字通道和各种其他低级组件。通常,只有在需要切换协议时才需要这样做。
代码示例来源:origin: org.simpleframework/simple-http
/**
* This provides the underlying channel for the request. It
* contains the TCP socket channel and various other low level
* components. Typically this will only ever be needed when
* there is a need to switch protocols.
*
* @return the underlying channel for this request
*/
public Channel getChannel() {
return request.getChannel();
}
代码示例来源:origin: ngallagher/simpleframework
/**
* This provides the underlying channel for the request. It
* contains the TCP socket channel and various other low level
* components. Typically this will only ever be needed when
* there is a need to switch protocols.
*
* @return the underlying channel for this request
*/
public Channel getChannel() {
return request.getChannel();
}
代码示例来源:origin: ngallagher/simpleframework
/**
* Constructor for the <code>OutputBarrier</code> object. This
* is used to ensure that if there is currently a blocking write
* in place that the <code>SessionChecker</code> will not end up
* being blocked if it attempts to send a control frame.
*
* @param request this is the request to get the TCP channel from
* @param duration this is the length of time to wait for the lock
*/
public OutputBarrier(Request request, long duration) {
this.lock = new ReentrantLock();
this.channel = request.getChannel();
this.writer = channel.getWriter();
this.duration = duration;
}
代码示例来源:origin: org.simpleframework/simple-http
/**
* Constructor for the <code>OutputBarrier</code> object. This
* is used to ensure that if there is currently a blocking write
* in place that the <code>SessionChecker</code> will not end up
* being blocked if it attempts to send a control frame.
*
* @param request this is the request to get the TCP channel from
* @param duration this is the length of time to wait for the lock
*/
public OutputBarrier(Request request, long duration) {
this.lock = new ReentrantLock();
this.channel = request.getChannel();
this.writer = channel.getWriter();
this.duration = duration;
}
代码示例来源:origin: ngallagher/simpleframework
/**
* Constructor for the <code>FrameEncoder</code> object. This is
* used to create an encoder to sending frames over the provided
* channel. Frames send remain unflushed so they can be batched
* on a single output buffer.
*
* @param request contains the opening handshake information
* @param charset this is the character encoding to encode with
*/
public FrameEncoder(Request request, String charset) {
this.barrier = new OutputBarrier(request, 5000);
this.channel = request.getChannel();
this.trace = channel.getTrace();
this.charset = charset;
}
代码示例来源:origin: org.simpleframework/simple-http
/**
* Constructor for the <code>FrameEncoder</code> object. This is
* used to create an encoder to sending frames over the provided
* channel. Frames send remain unflushed so they can be batched
* on a single output buffer.
*
* @param request contains the opening handshake information
* @param charset this is the character encoding to encode with
*/
public FrameEncoder(Request request, String charset) {
this.barrier = new OutputBarrier(request, 5000);
this.channel = request.getChannel();
this.trace = channel.getTrace();
this.charset = charset;
}
代码示例来源:origin: org.simpleframework/simple-http
/**
* Constructor for the <code>FrameCollector</code> object. This is
* used to create a collector that will process and dispatch web
* socket frames as defined by RFC 6455.
*
* @param encoder this is the encoder used to send messages
* @param session this is the web socket session
* @param channel this is the underlying TCP communication channel
* @param reactor this is the reactor used for read notifications
*/
public FrameCollector(FrameEncoder encoder, Session session, Request request, Reactor reactor) {
this.processor = new FrameProcessor(encoder, session, request);
this.channel = request.getChannel();
this.cursor = channel.getCursor();
this.trace = channel.getTrace();
this.reactor = reactor;
}
代码示例来源:origin: ngallagher/simpleframework
/**
* Constructor for the <code>FrameCollector</code> object. This is
* used to create a collector that will process and dispatch web
* socket frames as defined by RFC 6455.
*
* @param encoder this is the encoder used to send messages
* @param session this is the web socket session
* @param channel this is the underlying TCP communication channel
* @param reactor this is the reactor used for read notifications
*/
public FrameCollector(FrameEncoder encoder, Session session, Request request, Reactor reactor) {
this.processor = new FrameProcessor(encoder, session, request);
this.channel = request.getChannel();
this.cursor = channel.getCursor();
this.trace = channel.getTrace();
this.reactor = reactor;
}
代码示例来源:origin: org.simpleframework/simple-http
/**
* Constructor for the <code>FrameProcessor</code> object. This is
* used to create a processor that can consume and dispatch frames
* as defined by RFC 6455 to a set of registered listeners.
*
* @param encoder this is the encoder used to send control frames
* @param session this is the session associated with the channel
* @param channel this is the channel to read frames from
*/
public FrameProcessor(FrameEncoder encoder, Session session, Request request) {
this.listeners = new CopyOnWriteArraySet<FrameListener>();
this.normal = new Reason(NORMAL_CLOSURE);
this.extractor = new ReasonExtractor();
this.consumer = new FrameConsumer();
this.closed = new AtomicBoolean();
this.channel = request.getChannel();
this.cursor = channel.getCursor();
this.trace = channel.getTrace();
this.encoder = encoder;
this.session = session;
}
代码示例来源:origin: ngallagher/simpleframework
/**
* Constructor for the <code>FrameProcessor</code> object. This is
* used to create a processor that can consume and dispatch frames
* as defined by RFC 6455 to a set of registered listeners.
*
* @param encoder this is the encoder used to send control frames
* @param session this is the session associated with the channel
* @param channel this is the channel to read frames from
*/
public FrameProcessor(FrameEncoder encoder, Session session, Request request) {
this.listeners = new CopyOnWriteArraySet<FrameListener>();
this.normal = new Reason(NORMAL_CLOSURE);
this.extractor = new ReasonExtractor();
this.consumer = new FrameConsumer();
this.closed = new AtomicBoolean();
this.channel = request.getChannel();
this.cursor = channel.getCursor();
this.trace = channel.getTrace();
this.encoder = encoder;
this.session = session;
}
代码示例来源:origin: org.simpleframework/simple-http
/**
* Constructor for the <code>ResponseBuilder</code> object. In order
* to process the WebSocket handshake this requires the original
* request and the response as well as the underlying TCP channel
* which forms the basis of the WebSocket connection.
*
* @param request this is the request that initiated the handshake
* @param response this is the response for the handshake
*/
public ResponseBuilder(Request request, Response response) throws Exception {
this.validator = new RequestValidator(request);
this.token = new AcceptToken(request);
this.channel = request.getChannel();
this.writer = channel.getWriter();
this.trace = channel.getTrace();
this.response = response;
}
代码示例来源:origin: ngallagher/simpleframework
/**
* Constructor for the <code>ResponseBuilder</code> object. In order
* to process the WebSocket handshake this requires the original
* request and the response as well as the underlying TCP channel
* which forms the basis of the WebSocket connection.
*
* @param request this is the request that initiated the handshake
* @param response this is the response for the handshake
*/
public ResponseBuilder(Request request, Response response) throws Exception {
this.validator = new RequestValidator(request);
this.token = new AcceptToken(request);
this.channel = request.getChannel();
this.writer = channel.getWriter();
this.trace = channel.getTrace();
this.response = response;
}
代码示例来源:origin: org.simpleframework/simple-http
/**
* Constructor for the <code>StatusChecker</code> object. This
* is used to create a pinger that will send out ping frames at
* a specified interval. If a session does not respond within
* three times the duration of the ping the connection is reset.
*
* @param connection this is the WebSocket to send the frames
* @param request this is the associated request
* @param scheduler this is the scheduler used to execute this
* @param frequency this is the frequency with which to ping
*/
public StatusChecker(FrameConnection connection, Request request, Scheduler scheduler, long frequency) {
this.listener = new StatusResultListener(this);
this.error = new Reason(INTERNAL_SERVER_ERROR);
this.normal = new Reason(NORMAL_CLOSURE);
this.frame = new DataFrame(PING);
this.counter = new AtomicLong();
this.channel = request.getChannel();
this.trace = channel.getTrace();
this.connection = connection;
this.scheduler = scheduler;
this.frequency = frequency;
}
代码示例来源:origin: ngallagher/simpleframework
/**
* Constructor for the <code>StatusChecker</code> object. This
* is used to create a pinger that will send out ping frames at
* a specified interval. If a session does not respond within
* three times the duration of the ping the connection is reset.
*
* @param connection this is the WebSocket to send the frames
* @param request this is the associated request
* @param scheduler this is the scheduler used to execute this
* @param frequency this is the frequency with which to ping
*/
public StatusChecker(FrameConnection connection, Request request, Scheduler scheduler, long frequency) {
this.listener = new StatusResultListener(this);
this.error = new Reason(INTERNAL_SERVER_ERROR);
this.normal = new Reason(NORMAL_CLOSURE);
this.frame = new DataFrame(PING);
this.counter = new AtomicLong();
this.channel = request.getChannel();
this.trace = channel.getTrace();
this.connection = connection;
this.scheduler = scheduler;
this.frequency = frequency;
}
代码示例来源:origin: ngallagher/simpleframework
/**
* This method is used to terminate the connection and commit the
* response. Terminating the session before it has been dispatched
* is done when there is a protocol or an unexpected I/O error with
* the underlying TCP channel.
*
* @param request this is the session initiating request
* @param response this is the session initiating response
*/
public void terminate(Request request, Response response) {
Channel channel = request.getChannel();
Trace trace = channel.getTrace();
try {
response.close();
channel.close();
trace.trace(TERMINATE_SOCKET);
} catch(Exception cause) {
trace.trace(ERROR, cause);
}
}
}
代码示例来源:origin: org.simpleframework/simple-http
/**
* This method is used to terminate the connection and commit the
* response. Terminating the session before it has been dispatched
* is done when there is a protocol or an unexpected I/O error with
* the underlying TCP channel.
*
* @param request this is the session initiating request
* @param response this is the session initiating response
*/
public void terminate(Request request, Response response) {
Channel channel = request.getChannel();
Trace trace = channel.getTrace();
try {
response.close();
channel.close();
trace.trace(TERMINATE_SOCKET);
} catch(Exception cause) {
trace.trace(ERROR, cause);
}
}
}
代码示例来源:origin: ngallagher/simpleframework
/**
* Constructor for the <code>FrameConnection</code> object. This is used
* to create a channel that can read and write frames over a TCP
* channel. For asynchronous read and dispatch operations this will
* produce an operation to collect and process RFC 6455 frames.
*
* @param request this is the initiating request for the WebSocket
* @param response this is the initiating response for the WebSocket
* @param reactor this is the reactor used to process frames
*/
public FrameConnection(Request request, Response response, Reactor reactor) {
this.encoder = new FrameEncoder(request);
this.session = new ServiceSession(this, request, response);
this.operation = new FrameCollector(encoder, session, request, reactor);
this.reason = new Reason(NORMAL_CLOSURE);
this.channel = request.getChannel();
this.writer = channel.getWriter();
this.trace = channel.getTrace();
}
代码示例来源:origin: org.simpleframework/simple-http
/**
* Constructor for the <code>FrameConnection</code> object. This is used
* to create a channel that can read and write frames over a TCP
* channel. For asynchronous read and dispatch operations this will
* produce an operation to collect and process RFC 6455 frames.
*
* @param request this is the initiating request for the WebSocket
* @param response this is the initiating response for the WebSocket
* @param reactor this is the reactor used to process frames
*/
public FrameConnection(Request request, Response response, Reactor reactor) {
this.encoder = new FrameEncoder(request);
this.session = new ServiceSession(this, request, response);
this.operation = new FrameCollector(encoder, session, request, reactor);
this.reason = new Reason(NORMAL_CLOSURE);
this.channel = request.getChannel();
this.writer = channel.getWriter();
this.trace = channel.getTrace();
}
代码示例来源:origin: org.simpleframework/simple-http
/**
* This method is used to create a dispatch a <code>Session</code> to
* a specific service selected by a router. If the session initiating
* handshake fails for any reason this will close the underlying TCP
* connection and send a HTTP 400 response back to the client.
*
* @param request this is the session initiating request
* @param response this is the session initiating response
*/
public void dispatch(Request request, Response response) {
Channel channel = request.getChannel();
Trace trace = channel.getTrace();
try {
Service service = router.route(request, response);
Session session = builder.create(request, response);
trace.trace(DISPATCH_SOCKET);
service.connect(session);
} catch(Exception cause) {
trace.trace(ERROR, cause);
terminate(request, response);
}
}
代码示例来源:origin: ngallagher/simpleframework
/**
* This method is used to create a dispatch a <code>Session</code> to
* a specific service selected by a router. If the session initiating
* handshake fails for any reason this will close the underlying TCP
* connection and send a HTTP 400 response back to the client.
*
* @param request this is the session initiating request
* @param response this is the session initiating response
*/
public void dispatch(Request request, Response response) {
Channel channel = request.getChannel();
Trace trace = channel.getTrace();
try {
Service service = router.route(request, response);
Session session = builder.create(request, response);
trace.trace(DISPATCH_SOCKET);
service.connect(session);
} catch(Exception cause) {
trace.trace(ERROR, cause);
terminate(request, response);
}
}
内容来源于网络,如有侵权,请联系作者删除!