kaia-services.js
v0.0.3
Published
JS library for Kaia.ai services
Maintainers
Readme
Kaia-services.js
Services provided by Kaia.ai platform.
We have not yet launched the platform. For launch announcement please follow us on Facebook.
Live Demos
- Browse sample apps for live demos, source code
Installation
Kaia.ai robot apps run on Android smartphones. To run sample apps:
- Go to kaia.ai, familiarize yourself with how the robot platform works
- Optional, but highly recommended: if you don't have Kaia.ai account, create an account
- Go to Google Play, search for "kaia.ai" to find and install Kaia.ai Android app
- Launch Kaia.ai Android app on your Android smartphone
- In Kaia.ai Android app: (optional, but highly recommended): sign in, navigate to Kaia.ai App Store
- Choose a robot app to launch
- Optionally: click the heart icon to pin the robot app to your launch screen
API Overview
Messaging
let messaging = await createMessaging({ io: io(), eventListener: onMessageEvent, rooms: 'myRoom' });
// Send string or objects
messaging.send('Hello');
messaging.send({ firstName: 'Mary', lastName: 'Jane'});
...
function onMessageEvent(err, msg) {
if (err) {
print ('Error ' + err);
return;
}
switch (msg.event) {
case 'message':
print(msg.client + ' in room ' + msg.room + ' says ' + msg.message);
break;
case 'joined':
print(' ' + msg.room + ' clients now are ' + msg.clients);
print(msg.client + ' joined room ' + msg.room);
break;
case 'left':
print(' ' + msg.room + ' clients now are ' + msg.clients);
print(msg.client + ' left room ' + msg.room);
break;
case 'reconnect':
print('Reconnected');
break;
case 'disconnect':
print('Disconnected');
break;
}
}Installing
Via npm + webpack/rollup
npm install kaia-messaging.jsNow you can require/import kaia-messaging.js:
import { createMessaging } from 'kaia-messaging.js';Via <script>
dist/kaia-services.mjsis a valid JS module.dist/kaia-services-iife.jscan be used in browsers that don't support modules.kaiaServicesJsis created as a global.dist/kaia-services-iife.min.jsAs above, but minified.dist/kaia-services-iife-compat.min.jsAs above, but works in older browsers such as IE 10.dist/kaia-services-amd.jsis an AMD module.dist/kaia-services-amd.min.jsis a minified AMD module.
These built versions are also available on jsDelivr, e.g.:
<script src="https://cdn.jsdelivr.net/npm/kaia.js/dist/kaia-services-iife.min.js"></script>
<!-- Or in modern browsers: -->
<script type="module">
import { createMessaging } from 'https://cdn.jsdelivr.net/npm/kaia-services.js';
</script>and unpkg
<script src="https://unpkg.com/kaia.js/dist/kaia-services-iife.min.js"></script>
<!-- Or in modern browsers: -->
<script type="module">
import { createMessaging } from 'https://unpkg.com/kaia-services.js';
</script>