Registering a New User
To enable a user to establish a WebSocket connection, it is essential to first register them within your project. This registration process involves obtaining an authentication token specific to the user.
In the Ripple system, a user is identified by a combination of their user ID and session, separated by a two colons (::). The user ID typically matches the user ID in your own application. As for the session identifier, it should be a unique ID representing the session currently in use by the user for the WebSocket connection. This could be a unique device ID, tab ID, or even a client fingerprint.
For instance, if User A is accessing your application from both a PC and a mobile device, you could register them on each session as {userA.ID}::{desktop-session-id} and {userA.ID}::{mobile-session-id} respectively. This would enable you to send messages directly to a specific session (e.g., {userA.ID}::{mobile-session-id}) or to all sessions associated with a user (e.g., {userA.ID}).
POST /users
cURL
curl --location 'https://api.ripplesignal.co/users' \
--header 'x-secret-key: {your_secret_key}' \
--header 'Content-Type: application/json' \
--data '{
"user": "{your_user_id}::{session_id}"
}'
Response
Status Code: 200 OK
{
"token": "{user_token}"
}