Communication best practice
-
What is the best practice for communicating from a plugin to a web server?
I am interested in having a plugin temporarily connect to a web site and check some information in a database then disconnect.
Currently my plugin works on SU7, SU8 and SU2013 but has only been tested under Windows 7 and Windows 8. I am hoping that the plugin can also run under OSX
I could use Sockets or I could build a rest or soap Web Service.
I've heard that OSX includes a full Ruby install whereas Windows does not.
-
OSX ships with Ruby, yes, but SketchUp still uses its own Ruby core which is using Ruby 1.8.5. I think uptil OSX 10.8 it shipped with Ruby 1.8.7 but Mavericks ships with Ruby 2.0. You cannot expect the system Ruby to be compatible with SketchUp's ruby.
You might want to create a C Extensions that wraps a C/C++ socket or HTTP library.
-
Unfortunately that means I will have to purchase a Mac.
I do have C++Builder XE4 that will compile for Windows or OSX with a single code base. But licensing requires that you connect to a real Mac before you can compile for OSX.
The good part is there is unlimited deployment without license.
Is there no other sensible way for sketchup to connect to an external website?
-
Well you might try using a
UI::WebDialog
. -
Yes this is trivial with a webdialog.
I do this with a hidden iframe fetching a php page on my server, which connects to a database.
You can of course have the webdialog connecting to the php page without an iframe. -
Yes, if you need a UI Window open any way then you can use AJAX to poll.
-
@tt_su said:
Yes, if you need a UI Window open any way then you can use AJAX to poll.
I never succeeded to get ajax working with a local html file and a distant server, because of the same origin policy.
But I'm probably just too newbie -
If I remebered correctly Thomthom recommended JSONP for that. Have tried yet, but I have seen the recommendation in other places.
Edit: Here's the thread. but when rereading the post I realize this may not be relevant
http://sketchucation.com/forums/viewtopic.php?f=180%26amp;t=54288%26amp;p=492113#p492113
-
Yes, you must make the server dish out JSONP to comply with same-origin policy.
Advertisement