Trying to use third party lib (PubNub) to handle messaging

24 views
Skip to first unread message

green...@gmail.com

unread,
Apr 7, 2019, 1:34:48 AM4/7/19
to CodenameOne Discussions
It seems that CodenameOne doesn't support the third party lib, can anyone give advice for this?

39: error: package com.pubnub.api does not exist
       [javac] import com.pubnub.api.PNConfiguration;

40: error: package com.pubnub.api does not exist
       [javac] import com.pubnub.api.PubNub;

41: error: package com.pubnub.api.callbacks does not exist
       [javac] import com.pubnub.api.callbacks.PNCallback;

42: error: package com.pubnub.api.callbacks does not exist
       [javac] import com.pubnub.api.callbacks.SubscribeCallback;

43: error: package com.pubnub.api.enums does not exist
       [javac] import com.pubnub.api.enums.PNLogVerbosity;

44: error: package com.pubnub.api.models.consumer does not exist
       [javac] import com.pubnub.api.models.consumer.PNPublishResult;

45: error: package com.pubnub.api.models.consumer does not exist
       [javac] import com.pubnub.api.models.consumer.PNStatus;

46: error: package com.pubnub.api.models.consumer.access_manager does not exist
       [javac] import com.pubnub.api.models.consumer.access_manager.PNAccessManagerGrantResult;

47: error: package com.pubnub.api.models.consumer.pubsub does not exist
       [javac] import com.pubnub.api.models.consumer.pubsub.PNMessageResult;

48: error: package com.pubnub.api.models.consumer.pubsub does not exist
       [javac] import com.pubnub.api.models.consumer.pubsub.PNPresenceEventResult;

369: error: cannot find symbol
       [javac]     protected PNConfiguration pnConfiguration = new PNConfiguration();

370: error: cannot find symbol
       [javac]     protected PubNub pubnub= new PubNub(pnConfiguration);

Shai Almog

unread,
Apr 7, 2019, 10:00:37 PM4/7/19
to CodenameOne Discussions
This used to work fine. Make sure you included all the dependencies as pubnub included other dependencies. Also make sure you installed the library correctly.

green...@gmail.com

unread,
Apr 9, 2019, 8:25:05 AM4/9/19
to CodenameOne Discussions
Hi Shai,

I used below code to receive the message, but it didn't come. Do I need to execute this subscribe somewhere like original PubNub needs to execute after subscribe.

    public void subMessage() {
       
        Pubnub pubnub = new Pubnub(publishKey, subscribeKey);
       
        try {
           
            String channel = "testChannel";
            pubnub.subscribe(channel, new Callback() {
                @Override
                public void successCallback(String channel, Object message, String timetoken) {

                    System.out.println("Message is comming!!!!!!!!!!!!!!!!!!"+timetoken);
                }
            });

        }catch(PubnubException err) {
            Log.e(err);
            Dialog.show("Error", "There was a communication error: " + err, "OK", null);
        }
           
    }

Shai Almog

unread,
Apr 10, 2019, 12:36:58 AM4/10/19
to CodenameOne Discussions
Hi,
I think pubnub cut support for older libraries they implemented. I haven't paid much attention since websockets proved to be a good substitute and removed the need for solutions like that.

green...@gmail.com

unread,
Apr 10, 2019, 9:24:49 AM4/10/19
to CodenameOne Discussions
Where can I get the Websockets document and sample code? Then I can implement in my app as well, thanks!

Shai Almog

unread,
Apr 10, 2019, 10:14:53 PM4/10/19
to CodenameOne Discussions

Steve Hannah

unread,
Apr 10, 2019, 10:53:37 PM4/10/19
to codenameone...@googlegroups.com
There is also a WebSocket sample in the SampleRunner

The sample (a chat app), should run out of the box. Just download the CN1 sources, open the Sample Runner (instructions at link above), and click "Launch" next to the WebSocketSample.

On Wed, Apr 10, 2019 at 7:14 PM Shai Almog <shai....@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discu...@googlegroups.com.
Visit this group at https://groups.google.com/group/codenameone-discussions.
To view this discussion on the web visit https://groups.google.com/d/msgid/codenameone-discussions/e1a9b0d3-a28c-4fa9-a374-198eae7877f9%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


--
Steve Hannah
Web Lite Solutions Corp.
Message has been deleted

green...@gmail.com

unread,
Apr 11, 2019, 6:30:58 PM4/11/19
to CodenameOne Discussions
Hi Shai,

I changed to Websocket, and it works perfectly for me now.

Thanks!

On Thursday, April 11, 2019 at 4:14:53 AM UTC+2, Shai Almog wrote:

green...@gmail.com

unread,
Apr 11, 2019, 6:31:47 PM4/11/19
to CodenameOne Discussions
Thanks!

It works for me now.

On Thursday, April 11, 2019 at 4:53:37 AM UTC+2, shannah wrote:
There is also a WebSocket sample in the SampleRunner

The sample (a chat app), should run out of the box. Just download the CN1 sources, open the Sample Runner (instructions at link above), and click "Launch" next to the WebSocketSample.

On Wed, Apr 10, 2019 at 7:14 PM Shai Almog <shai...@gmail.com> wrote:

--
You received this message because you are subscribed to the Google Groups "CodenameOne Discussions" group.
To unsubscribe from this group and stop receiving emails from it, send an email to codenameone-discussions+unsub...@googlegroups.com.
Reply all
Reply to author
Forward
0 new messages