Start line:  
End line:  

Snippet Preview

Snippet HTML Code

Stack Overflow Questions
The MIT License Copyright (c) 2010 Tad Glines Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 package com.glines.socketio.server.transport;
 public abstract class AbstractHttpTransport extends AbstractTransport {
This is a sane default based on the timeout values of various browsers.
 	public static final long HTTP_REQUEST_TIMEOUT = 30*1000;

The amount of time the session will wait before trying to send a ping. Using a value of half the HTTP_REQUEST_TIMEOUT should be good enough.
 	public static final long HEARTBEAT_DELAY = /2;

This specifies how long to wait for a pong (ping response).
 	public static final long HEARTBEAT_TIMEOUT = 10*1000;

For non persistent connection transports, this is the amount of time to wait for messages before returning empty results.
 	public static long REQUEST_TIMEOUT = 20*1000;
 	protected static final String SESSION_KEY = "com.glines.socketio.server.AbstractHttpTransport.Session";
 	public AbstractHttpTransport() {
 	protected abstract SocketIOSession connect(
 			HttpServletResponse response,
 			Transport.InboundFactory inboundFactory,
 			SocketIOSession.Factory sessionFactorythrows IOException;
 	public void handle(HttpServletRequest request,
 			HttpServletResponse response,
 			Transport.InboundFactory inboundFactory,
 			SocketIOSession.Factory sessionFactory)
 			throws IOException {
 		Object obj = request.getAttribute();
 		SocketIOSession session = null;
 		String sessionId = null;
 		if (obj != null) {
 			session = (SocketIOSession)obj;
 		} else {
 			sessionId = extractSessionId(request);
 			if (sessionId != null && sessionId.length() > 0) {
 				session = sessionFactory.getSession(sessionId);
 		if (session != null) {
 			if (handler != null) {
 			} else {
 		} else if (sessionId != null && sessionId.length() > 0) {
 		} else {
 			if ("GET".equals(request.getMethod())) {
 				session = connect(requestresponseinboundFactorysessionFactory);
				if (session == null) {
else {
New to GrepCode? Check out our FAQ X