What does Phidget22.Connection do?

Supporting Browser-based Javascript and Node.js
Post Reply
khun
Phidgetly
Posts: 29
Joined: Tue Oct 27, 2020 8:44 am
Contact:

What does Phidget22.Connection do?

Post by khun »

I find examples like these for web pages:

function connectPhidgets() {
var local = location.hostname; //get host location
var conn = new phidget22.Connection(8080, local);
conn.connect().then(runExample);
}

What is happening here? Why would I need to do this in a web page (index.html), in python I just open the DigitalOutput without making any "connection"?
User avatar
Patrick
Lead Developer
Posts: 3399
Joined: Mon Jun 20, 2005 8:46 am
Location: Canada
Contact:

Re: What does Phidget22.Connection do?

Post by Patrick »

From the browser, Phidgets are opened via the phidget22networkserver. The Connection object is creating a connection to the local server to access the Phidgets. Other languages have different APIs for the network connection options.

Make sure your network server is installed and running. I saw you made some other posts - if things work properly and then stop working, make sure that the network server daemon is still running, or have a look in the network server logs to see what may be wrong.

-Patrick
khun
Phidgetly
Posts: 29
Joined: Tue Oct 27, 2020 8:44 am
Contact:

Re: What does Phidget22.Connection do?

Post by khun »

Thanks for the reply.

I don't know how to check for those things, but I suddenly realized that the problem now seems to be user rights again, which I am discussing in another thread (I can't run phidget22admin without sudo).

So I'm happy with the answer here for now, I was just wondering what the "connection" was for.
Post Reply

Who is online

Users browsing this forum: No registered users and 0 guests