?? mytestsimple.java
字號:
package hfut.wispy.Client;
import nl.justobjects.pushlet.client.PushletClient;
import nl.justobjects.pushlet.client.PushletClientListener;
import nl.justobjects.pushlet.core.Event;
import nl.justobjects.pushlet.core.Protocol;
import nl.justobjects.pushlet.util.PushletException;
public class MyTestSimple implements PushletClientListener, Protocol {
private static String SUBJECT = "/wyyCity";
private static final String MODE = MODE_STREAM;
public MyTestSimple(String aHost, int aPort) {
// Create and start a Pushlet client; we receive callbacks
// through onHeartbeat() and onData().
try {
PushletClient pushletClient = new PushletClient(aHost, aPort);
pushletClient.setDebug(true);
pushletClient.join();
// pushletClient.listen(this, MODE, SUBJECT);
pushletClient.joinListen(this, MODE, SUBJECT);
System.out.println("here pushletClient started");
p("pushletClient started MyTest");
} catch (PushletException pe) {
p("Error in setting up pushlet session pe=" + pe);
}
}
/** Error occurred. */
public void onError(String message) {
p("onAbort onError: " + message);
}
/** Abort event from server. */
public void onAbort(Event theEvent) {
p("onAbort received: " + theEvent.toString());
}
/** Data event from server. */
public void onData(Event theEvent) {
// Calculate round trip delay
// p("theEvent.toXML() : " + theEvent.toXML());
// p("here is the city :" + theEvent.getField("city"));
p("number : " + theEvent.getField("number"));
p("city : " + theEvent.getField("city"));
p("value : " + theEvent.getField("value"));
}
/** Heartbeat event from server. */
public void onHeartbeat(Event theEvent) {
p("onHeartbeat received: " + theEvent.toString());
}
/** Generic print. */
public static void p(String s) {
System.out.println("[MyTest] " + s);
}
/**
* @param args
*/
public static void main(String[] args) {
// TODO 自動生成方法存根
new MyTestSimple("localhost", 8080);
}
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -