所以,我现在已经做了一段时间了,并且不知道该怎么做。
import java.awt.EventQueue;
import com.pusher.client.Pusher;
import com.pusher.client.channel.Channel;
import com.pusher.client.channel.ChannelEventListener;
import com.pusher.client.channel.SubscriptionEventListener;
import com.pusher.client.connection.ConnectionEventListener;
import com.pusher.client.connection.ConnectionState;
import com.pusher.client.connection.ConnectionStateChange;
public class Testic
{
public static void main(String[] args)
{
EventQueue.invokeLater(new Runnable() {
public void run() {
try {
// Create a new Pusher instance
Pusher pusher = new Pusher("de504dc5763aeef9ff52");
pusher.connect(new ConnectionEventListener()
{
@Override
public void onConnectionStateChange(ConnectionStateChange change)
{
System.out.println("State changed to " + change.getCurrentState() +
" from " + change.getPreviousState());
}
@Override
public void onError(String message, String code, Exception e)
{
System.out.println("There was a problem connecting!");
}
}, ConnectionState.ALL);
// Subscribe to a channel
Channel channel = pusher.subscribe("order_book", new ChannelEventListener() {
@Override
public void onSubscriptionSucceeded(String channelName) {
System.out.println("Subscribed!");
}
@Override
public void onEvent(String channelName, String eventName, String data) {
System.out.println("desilo se");
}
}, "bids", "asks");
// Bind to listen for events called "my-event" sent to "my-channel"
channel.bind("data", new SubscriptionEventListener() {
@Override
public void onEvent(String channel, String event, String data) {
System.out.println("Received event with data: " + data);
}
});
} catch (Exception e) {
e.printStackTrace();
}
}
});
}
}
我正在尝试read websocket API from Bitstamp直播订单。当我运行它时,它只是说:State changed to CONNECTING from DISCONNECTED
。它没有"循环"但只是停下来。我按照here安装了推送依赖项。
我真的不知道该怎么做。