Get Started
For start working with Rotor, you must connect your server (API) and clients (only Android yet) with Redis.
Install Redis before follow this guide.
Prepare Rotor Server
Let’s prepare a Rotor server over your API.
Install the package:
npm install rotor-server --save
And start the server:
const RotorServer = require('rotor-server');
const RS = new RotorServer({
"server_port": 1508,
"turbine_port": 1510,
"redis_port": 6379,
"databases": ["database"],
"debug": true
});
RS.start();
start()
method will launch Redis server (if it’s dead), Rotor server and Turbine (database manager). For more information about Turbine, check out this link.
databases
param defines a list of database names for loading it. If any database doesn’t exist, it will be created.
Prepare Rotor Client
Implement Rotor Core on build.gradle file.
android {
defaultConfig {
multiDexEnabled true
}
}
def rotor_version = "0.3"
dependencies {
implementation ("com.rotor:core:$rotor_version@aar") {
transitive = true
}
}
transitive
flag is needed for implementing Rotor Core dependencies
Add Rotor service in AndroidManifest.xml
:
<service
android:name="com.rotor.core.RotorService"
android:exported="false" />
Initialize Rotor Core in your launcher activity. Once the library connects with Redis server, application workflow can continue.
Rotor.initialize(getApplicationContext(), "http://10.0.2.2:1508/",
"redis://10.0.2.2", new StatusListener() {
@Override
public void connected() {
// continue to other activity or checking permissions..
}
@Override
public void reconnecting() {
}
}
);
Now your app is ready to implement real-time databases and notifications.