RPC is a way to locally interact with Nerimity. It allows you to send rich activity to Nerimity. For example, showing which music you're listening to, along with the progress bar, art and url.
There are currently 2 ways to connect to RPC:
WebSocket Server For The Desktop App
Post Message Through Browser
You can connect to the desktop app by using the WebSocket Server.
To find the localhost port for the WebSocket Server, you will need to:
- Scan through port ranges
6463
to6472
- Connect to each port, and see if
HELLO_NERIMITY_RPC
is received. - if it is not received, try the next port.
- if it is received, You are now connected to the WebSocket Server.
You can now emit events to the websocket server.
{
type: 'UPDATE_RPC',
data: {
name: string;
link?: string;
action?: string;
title?: string;
subtitle?: string;
imgSrc?: string;
startedAt?: number;
endsAt?: number;
}
}
RPC Data Types
To clear the RPC, send the above event but with data set to null.
You can post messages using iframe or Chrome/FireFox Extensions.
When Nerimity finishes authenticating, it will post a message NERIMITY_READY
to the parent window. This means that the client is ready to accept events.
To Listen to the NERIMITY_READY
message, you can use the following code:
window.onmessage = (event) => {
if (event.data === "NERIMITY_READY") {
// Nerimity is ready
}
};
After the NERIMITY_READY
message is received, you can send messages to Nerimity by using the postMessage
function.
document.getElementById('cross_domain_page').contentWindow.postMessage({
type: 'UPDATE_RPC',
data: {
name: string;
link?: string;
action?: string;
title?: string;
subtitle?: string;
imgSrc?: string;
startedAt?: number;
endsAt?: number;
}
})
RPC Data Types
To clear the RPC, send the above event but with data set to null.