This page provides important information for users of the Ice for JavaScript distribution.
On this page:
Ice for JavaScript is available as npm and bower packages. The following npm packages are provided for Node.js developers:
slice2js
with the gulp build systemThe following bower package is provided for developers of browser-based applications:
Install the Ice for JavaScript run time libraries using npm
:
npm install ice@3.6 --save |
This package also includes the browser version of Ice for JavaScript in node_modules/lib
.
To install with bower
:
bower install ice --save |
You can also run |
The Slice-to-JavaScript compiler (slice2js
) can be installed with this command:
npm install slice2js@3.6 --save-dev |
This command builds the compiler from source therefore you must have a supported C++ compiler installed.
In order to use |
The slice2js
package includes all of the standard Slice files and automatically adds the slice directory to the include file search path.
The Ice manual provides a complete description of the JavaScript mapping.
You can use several top-level Ice package in your Node.js applications, as shown below:
var Ice = require('ice').Ice; var Glacier2 = require('ice').Glacier2; var IceStorm = require('ice').IceStorm; var IceGrid = require('ice').IceGrid; var communicator = Ice.initialize(process.argv); var proxy = communicator.stringToProxy("hello:tcp -h localhost -p 10000"); |
Add the necessary <script>
tags to your html to include the Ice for JavaScript components you require.
<script src="/bower_components/ice/lib/Ice.js"></script> <script src="/bower_components/ice/lib/Glacier2.js"></script> <script src="/bower_components/ice/lib/IceStorm.js"></script> <script src="/bower_components/ice/lib/IceGrid.js"></script> <script type="text/javascript"> var communicator = Ice.initialize(); var proxy = communicator.stringToProxy("hello:ws -h localhost -p 10002"); </script> |
Minified versions are available with the .min.js
extension.
The Ice for JavaScript browser libraries are also available through cdnjs.
<script src="https://cdnjs.cloudflare.com/ajax/libs/ice/3.6.4/Ice.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/ice/3.6.4/Glacier2.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/ice/3.6.4/IceStorm.min.js"></script> <script src="https://cdnjs.cloudflare.com/ajax/libs/ice/3.6.4/IceGrid.min.js"></script> |
A CDN is a great option for applications that do not wish to host all of their website's files themselves. Among other things, using a CDN will help to reduce bandwidth and allow caching across multiple websites. Note however that you will still need to serve your client JavaScript files yourself. |
You can execute the Slice-to-JavaScript compiler from code as shown below:
var slice2js = require('slice2js'); slice2js.compile(["Hello.ice"]); |
If you installed the slice2js
package globally, you can also run slice2js
on the command line.
Refer to the manual for a description of the arguments accepted by slice2js
.
The Ice sample programs are provided in a GitHub repository. You can browse this repository to see build and usage instructions for all supported programming languages. Simply clone this repository and use its 3.6 branch:
git clone -b 3.6 https://github.com/zeroc-ice/ice-demos.git cd ice-demos |