• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Trying to use PubNub java object - the "hereNow" method.

New Here ,
Jun 06, 2016 Jun 06, 2016

Copy link to clipboard

Copied

I have included the Pubnub-4.0.0.jar file into my webroot.

(Pubnub-4.0.0.jar can be downloaded here: https://www.pubnub.com/docs/java/pubnub-java-sdk-v4)

I am trying to get the “HERE NOW” java code into my coldfusion project and am having some trouble in doing so.

The java code is as follows:

PNConfiguration pnConfiguration = new PNConfiguration();

pnConfiguration.setSubscribeKey("SubscribeKey")  

PubNub pubnub = new PubNub(pnConfiguration);

pubNub.hereNow()

    .channels(Arrays.asList("ch1", "ch2", "ch3")) // who is present on those channels?

    .includeState(true) // include state with request (false by default)

    .includeUUIDs(true) // if false, only shows occupancy count

    .async(new PNCallback<PNHereNowResult>() {

        @Override

        public void onResponse(PNHereNowResult result, PNStatus status) {

        }

    });

My corresponding Coldfusion code is as follows:

<cfobject type="java" class="com.pubnub.api.PNConfiguration" name="objPNConfiguration" >

<cfset PNConfiguration = objPNConfiguration.init() >

<cfset PNConfiguration.setSubscribeKey("SubscribeKey") >

<cfobject type="java" class="com.pubnub.api.PubNub" name="objPubNub" >

<cfset pubnub = objPubNub.init(PNConfiguration) >

<cfset tmp = pubnub.hereNow({channels: "ch1"}) >

<cfdump var="#tmp#" >

I do not get any errors returned.

I feel the way in which I am calling the “hereNow” method is incorrect or the way in which I am trying to display the results is incorrect.

Can anyone provide any assistance with regards to this?

Thanks

Views

315

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 06, 2016 Jun 06, 2016

Copy link to clipboard

Copied

You might be able to place a .jar file in webroot and get it to work, but I don't think it's a good idea.

The .jar files should all go into a specific folder, and a path to the class added in CFAdmin, then the service restarted.  That should make the .jar available to CF.  Then your CF code should work.

HTH,

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2016 Jun 06, 2016

Copy link to clipboard

Copied

Thanks for your reply.

I have taken your advice.

The result is the same.

The CF code is working I assume because I am not getting any errors.

The issue is that I'm not getting any output from my call.

I feel the issue is in my code conversion - java to coldfusion. (specifically the pubnub.herenow method call)

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
Jun 06, 2016 Jun 06, 2016

Copy link to clipboard

Copied

If you're not seeing any error messages, but it's not being set (have you tried a CFDUMP of the object, itself?), then check the logs in CFAdmin.. one of them should have some indication of what is going on.

I'm not familiar with pubnub, nor do I use third-party Java classes, so I'm not much help in this area.  And I hate to sound condescending, but even after 15 years, I still make some rookie mistakes, so I must ask.  Did you restart the CF service after placing the .jar file in the proper folder and adding the path to the JVM class in CFAdmin?

HTH,

^_^

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
New Here ,
Jun 06, 2016 Jun 06, 2016

Copy link to clipboard

Copied

LATEST

Yes, I completed the restart of the CF service.

Thanks

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation