Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@stephentu
Created January 31, 2013 01:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save stephentu/4678994 to your computer and use it in GitHub Desktop.
Save stephentu/4678994 to your computer and use it in GitHub Desktop.
import java.net.URI;
import java.net.URISyntaxException;
import org.java_websocket.WebSocketImpl;
import org.java_websocket.client.WebSocketClient;
import org.java_websocket.handshake.ServerHandshake;
public class TestWS {
public static class TestClient extends WebSocketClient {
public TestClient(URI serverURI) {
super(serverURI, new org.java_websocket.drafts.Draft_10());
}
@Override
public void onClose(int arg0, String arg1, boolean arg2) {
// TODO Auto-generated method stub
}
@Override
public void onError(Exception arg0) {
arg0.printStackTrace();
}
@Override
public void onMessage(String arg0) {
System.out.println("onMessage:" + arg0);
}
@Override
public void onOpen(ServerHandshake arg0) {
System.out.println("onOpen:" + arg0);
send("HELLOdasfdaskjgkldjaskljasdkldasgdas");
}
}
/**
* @param args
* @throws URISyntaxException
*/
public static void main(String[] args) throws URISyntaxException {
WebSocketImpl.DEBUG=true;
TestClient c = new TestClient(new URI("ws://modis.csail.mit.edu:50007"));
c.connect();
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment