pusher / pusher-websocket-java

Pusher Channels client library for Java targeting general Java and Android
Other
309 stars 143 forks source link

PusherEvent push data in fragment twice #272

Open hafiz013 opened 4 years ago

hafiz013 commented 4 years ago

Below here my code inside fragment:

`options = new PusherOptions(); options.setCluster(cluster_pusher);

    pusher = new Pusher(key_pusher, options);

    pusher.connect(new ConnectionEventListener() {
        @Override
        public void onConnectionStateChange(ConnectionStateChange change) {
            Log.i("Pusher", "State changed from " + change.getPreviousState() +
                    " to " + change.getCurrentState());
        }

        @Override
        public void onError(String message, String code, Exception e) {
            Log.i("Pusher", "There was a problem connecting! " +
                    "\ncode: " + code +
                    "\nmessage: " + message +
                    "\nException: " + e
            );
        }
    }, ConnectionState.ALL);

    channel = pusher.subscribe(Config.TOPIC_GLOBAL);

      channel.bind(Config.PUSHER_EVENT, new SubscriptionEventListener() {
        @Override
        public void onEvent(PusherEvent event) {
            Log.i("Pusher", "Received event with data: " + event.getData());

} });`

why?

daniellevass commented 4 years ago

Hi,

Can you please explain what's happening and what you expected to happen in more detail? This appears to be the same code snippet we provide in the readme and should write to the logcat for every message received.

Thank you,

hafiz013 commented 4 years ago

expected data receive from event.getData(): 1) one time only {"type":"LiveBid","server_time":"2020-07-09 17:17:38","time_expire":"17:19:38","bid":"28","title":"Test PINENG PN-939 20000mAh 3 Input Lithium Polymer Power Bank - Black \/ White","current_price":"21.25","bidder_name":"hafiz_test","bid_status":"Active"}

but i received twice: {"type":"LiveBid","server_time":"2020-07-09 17:17:38","time_expire":"17:19:38","bid":"28","title":"Test PINENG PN-939 20000mAh 3 Input Lithium Polymer Power Bank - Black \/ White","current_price":"21.25","bidder_name":"hafiz_test","bid_status":"Active"} {"type":"LiveBid","server_time":"2020-07-09 17:17:38","time_expire":"17:19:38","bid":"28","title":"Test PINENG PN-939 20000mAh 3 Input Lithium Polymer Power Bank - Black \/ White","current_price":"21.25","bidder_name":"hafiz_test","bid_status":"Active"}