ODIN Node JS
Native Node JS bindings for the ODIN SDK. It is based on the ODIN Native SDK and wraps the C++ code into a Node JS module.
Check out documentation and guides at developers.4players.io.
This SDK is currently in beta. This means that the API is not final and might change in the future. It's also not ready for production use as there might be bugs, memory leaks or other issues. But it's good enough for testing AI integration, recording or other interesting use cases.
If you have any questions or feedback, please reach out to us at our Discord Server.
ODIN Node JS compared to Web SDK
While we try to keep the API as similar as possible, there are some differences. While wrapping things in objects in
to only use C/C++ and objects where required. For example, the WebSDK provides an
OdinPeer object that wraps various
methods and properties. For bots and other NodeJS use cases you typically don't need that and therefore we decided to
not make things more complex than required. You typically only get a
mediaId and that's it. But for most
use cases this is enough, and you are always free to build your own wrapper where required.
The most prominent difference is, that the NodeJS SDK allows you to get the raw audio data from the ODIN server. This allows you to record audio or sending audio into the room. While the WebSDK provides a similar functionality it is based on Web Audio that is not available on NodeJS - therefore it does not make much sense to wrap and polyfill all of that while it's super easy (and fast) to wrap the ODIN native SDK into NodeJS bindings.
Having two libs also allows us to optimize for each platform without having to work through many use cases.
You need to have a C++ compiler installed. On macOS, you can install XCode and the command line tools. On Linux you need to have GCC installed. More information can be found here: node-gyp.
Getting Started and compiling
Add the package to your project:
npm install --save @4players/odin-nodejs
This will compile the NodeJS bindings for the "local" machine. We provide a few precompiled libraries so you don't need to have GCC and compilers installed. This is especially useful for CI/CD pipelines.
It has deps to the native ODIN SDK. A couple of libraries for typical use cases (i.e. macOS, Windows and Linux) is provided
libs folder. If you have some fancy platform, you might need to compile the ODIN SDK and put the lib in the
folder according this name scheme:
We provide a few examples in the
tests folder to get you started quickly.