Created
January 31, 2013 01:12
-
-
Save stephentu/4678994 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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