Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
("Websocket connection disposal with Jetty")

Solution provided by Jim Marino at gmail [dot] com
  • Loading branch information
jfarcand committed Sep 15, 2010
1 parent ac80b73 commit 1c97bea
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 12 deletions.
Expand Up @@ -60,20 +60,22 @@ public void redirect(String location) throws IOException {
}

public void write(byte frame, String data) throws IOException {
if (!outbound.isOpen()) throw new IOException("Connection closed");
outbound.sendMessage(frame, data);
}

public void write(byte frame, byte[] data) throws IOException {
if (!outbound.isOpen()) throw new IOException("Connection closed");
outbound.sendMessage(frame, data, 0, data.length);
}

public void write(byte frame, byte[] data, int offset, int length) throws IOException {
if (!outbound.isOpen()) throw new IOException("Connection closed");
outbound.sendMessage(frame, data, offset, length);
}

public void close() throws IOException {
outbound.disconnect();
}


}
Expand Up @@ -36,8 +36,6 @@
*/
package org.atmosphere.websocket;

import org.atmosphere.util.LoggerUtils;

import javax.servlet.ServletOutputStream;
import javax.servlet.ServletResponse;
import javax.servlet.http.Cookie;
Expand All @@ -50,7 +48,6 @@
import java.util.Collections;
import java.util.HashMap;
import java.util.Locale;
import java.util.logging.Level;

/**
* Wrapper around an {@link HttpServletResponse} which use an instance of {@link WebSocketSupport}
Expand Down Expand Up @@ -418,35 +415,31 @@ public void write(char[] chars, int offset, int lenght) {
try {
webSocketSupport.write(frame, new String(chars, offset, lenght));
} catch (IOException e) {
LoggerUtils.getLogger().log(Level.INFO, "", e);

throw new RuntimeException(e);
}
}

public void write(char[] chars) {
try {
webSocketSupport.write(frame, new String(chars));
} catch (IOException e) {
LoggerUtils.getLogger().log(Level.INFO, "", e);

throw new RuntimeException(e);
}
}

public void write(String s, int offset, int lenght) {
try {
webSocketSupport.write(frame, new String(s.substring(offset, lenght)));
} catch (IOException e) {
LoggerUtils.getLogger().log(Level.INFO, "", e);

throw new RuntimeException(e);
}
}

public void write(java.lang.String s) {
try {
webSocketSupport.write(frame, new String(s));
} catch (IOException e) {
LoggerUtils.getLogger().log(Level.INFO, "", e);

throw new RuntimeException(e);
}
}
};
Expand Down

0 comments on commit 1c97bea

Please sign in to comment.