Skip to content

Commit

Permalink
extracting jetty-specific classes
Browse files Browse the repository at this point in the history
  • Loading branch information
mathieucarbou committed Feb 10, 2011
1 parent 810ffd2 commit 2c172df
Show file tree
Hide file tree
Showing 9 changed files with 449 additions and 434 deletions.
Expand Up @@ -34,17 +34,17 @@

import com.glines.socketio.server.SocketIOFrame;
import com.glines.socketio.server.SocketIOSession;
import com.glines.socketio.server.transport.ConnectionTimeoutPreventor.IdleCheck;
import com.glines.socketio.server.transport.JettyConnectionTimeoutPreventor.IdleCheck;
import com.glines.socketio.util.JSON;

public class HTMLFileTransport extends JettyXHRTransport {
public class HTMLFileTransport extends XHRTransport {
public static final String TRANSPORT_NAME = "htmlfile";

private class HTMLFileSessionHelper extends XHRSessionHelper {
private class HTMLFileSessionHelper extends JettyXHRSessionHelper {
private final IdleCheck idleCheck;

HTMLFileSessionHelper(SocketIOSession session, IdleCheck idleCheck) {
super(session, true);
HTMLFileSessionHelper(SocketIOSession session, IdleCheck idleCheck, int bufferSize, int maxIdleTime) {
super(session, true, bufferSize, maxIdleTime);
this.idleCheck = idleCheck;
}

Expand Down Expand Up @@ -84,8 +84,8 @@ public String getName() {
return TRANSPORT_NAME;
}

protected XHRSessionHelper createHelper(SocketIOSession session) {
IdleCheck idleCheck = ConnectionTimeoutPreventor.newTimeoutPreventor();
return new HTMLFileSessionHelper(session, idleCheck);
protected JettyXHRSessionHelper createHelper(SocketIOSession session, int bufferSize, int maxIdleTime) {
IdleCheck idleCheck = JettyConnectionTimeoutPreventor.newTimeoutPreventor();
return new HTMLFileSessionHelper(session, idleCheck, bufferSize, maxIdleTime);
}
}
Expand Up @@ -35,7 +35,7 @@
import com.glines.socketio.server.TransportAdapter;
import com.glines.socketio.util.Web;

public abstract class AbstractHttpTransport extends TransportAdapter {
public abstract class HttpTransport extends TransportAdapter {
/**
* This is a sane default based on the timeout values of various browsers.
*/
Expand All @@ -58,10 +58,7 @@ public abstract class AbstractHttpTransport extends TransportAdapter {
*/
public static long REQUEST_TIMEOUT = 20*1000;

protected static final String SESSION_KEY = AbstractHttpTransport.class.getName() + ".Session";

public AbstractHttpTransport() {
}
protected static final String SESSION_KEY = HttpTransport.class.getName() + ".Session";

protected abstract SocketIOSession connect(
HttpServletRequest request,
Expand All @@ -70,7 +67,7 @@ protected abstract SocketIOSession connect(
SocketIOSession.Factory sessionFactory) throws IOException;

@Override
public void handle(HttpServletRequest request,
public final void handle(HttpServletRequest request,
HttpServletResponse response,
Transport.InboundFactory inboundFactory,
SocketIOSession.Factory sessionFactory)
Expand Down
Expand Up @@ -33,14 +33,14 @@
import com.glines.socketio.server.SocketIOFrame;
import com.glines.socketio.server.SocketIOSession;

public class JSONPPollingTransport extends JettyXHRTransport {
public class JSONPPollingTransport extends XHRTransport {
public static final String TRANSPORT_NAME = "jsonp-polling";
private long jsonpIndex = -1;

protected class XHRPollingSessionHelper extends XHRSessionHelper {
protected class XHRPollingSessionHelper extends JettyXHRSessionHelper {

XHRPollingSessionHelper(SocketIOSession session) {
super(session, false);
XHRPollingSessionHelper(SocketIOSession session, int bufferSize, int maxIdleTime) {
super(session, false, bufferSize, maxIdleTime);
}

protected void startSend(HttpServletResponse response) throws IOException {
Expand Down Expand Up @@ -82,7 +82,7 @@ public String getName() {
}


protected XHRPollingSessionHelper createHelper(SocketIOSession session) {
return new XHRPollingSessionHelper(session);
protected XHRPollingSessionHelper createHelper(SocketIOSession session, int bufferSize, int maxIdleTime) {
return new XHRPollingSessionHelper(session, bufferSize, maxIdleTime);
}
}
Expand Up @@ -35,7 +35,7 @@
* SocketIO transport. IN order to prevent this, without disabling the maxIdleTime completely,
* this class is used to obtain a @{link IdleCheck} instance that can be used to reset the idle timeout.
*/
final class ConnectionTimeoutPreventor {
final class JettyConnectionTimeoutPreventor {
interface IdleCheck {
void activity();
}
Expand Down

0 comments on commit 2c172df

Please sign in to comment.