A WebSocket server that integrates with PluralKit API to enable front switching in Resonite using ProtoFlux.
- ๐ Real-time front switching via WebSocket
- ๐ก PluralKit API integration
- ๐ฎ ProtoFlux-compatible client
- โ๏ธ Easy configuration via JSON file
- ๐ Multiple client support
- ๐ Real-time member information
- ๐จ Member color support
- ๐ Name-based member switching
npm install
- Get your PluralKit token from PluralKit.me
- Get your system ID from your PluralKit dashboard
- Copy the example config and fill in your details:
cp config.example.json config.json
- Edit
config.json
with your actual token and system ID:
{
"pluralkit": {
"token": "your_actual_pluralkit_token_here",
"systemId": "your_system_id_here"
},
"websocket": {
"port": 8080,
"host": "localhost"
}
}
npm start
For development with auto-restart:
npm run dev
The server accepts the following message types:
{
"type": "switch_front",
"data": {
"memberId": "member_id_here"
}
}
{
"type": "get_current_front",
"data": {}
}
{
"type": "get_members",
"data": {}
}
{
"type": "ping",
"data": {}
}
{
"type": "connected",
"data": {
"clientId": "unique_client_id",
"currentFront": {
"id": "member_id",
"name": "Member Name",
"displayName": "Display Name",
"pronouns": "they/them"
},
"availableMembers": [...]
}
}
{
"type": "front_switched",
"data": {
"member": {
"id": "member_id",
"name": "Member Name",
"displayName": "Display Name",
"pronouns": "they/them"
},
"timestamp": 1234567890
}
}
{
"type": "error",
"data": {
"message": "Error description"
}
}
In ProtoFlux, you can connect to the WebSocket server using:
- WebSocket Connect Node: Set URL to
ws://localhost:8080
- WebSocket Send Node: Send JSON messages as strings
- WebSocket Receive Node: Parse incoming JSON messages
- Connect: Use WebSocket Connect node
- Send Switch Command:
- Create a JSON string:
{"type":"switch_front","data":{"memberId":"your_member_id"}}
- Send via WebSocket Send node
- Create a JSON string:
- Handle Response:
- Receive via WebSocket Receive node
- Parse JSON and check message type
- Update UI or trigger other actions
For testing or advanced usage, you can use the provided JavaScript client:
const PluralKitWebSocketClient = require('./protoflux-client');
const client = new PluralKitWebSocketClient('ws://localhost:8080');
// Connect
await client.connect();
// Switch front by member ID
client.switchFront('member_id_here');
// Switch front by name
client.switchFrontByName('Member Name');
// Get current front
client.getCurrentFront();
// Get all members
client.getMembers();
{
"pluralkit": {
"token": "your_pluralkit_token",
"systemId": "your_system_id"
},
"websocket": {
"port": 8080,
"host": "localhost"
},
"logging": {
"level": "info",
"logToFile": true
}
}
-
"Please set your PluralKit token"
- Make sure you've updated
config.json
with your actual token
- Make sure you've updated
-
"Member not found"
- Verify the member ID exists in your system
- Check that the member is active
-
WebSocket connection failed
- Ensure the server is running
- Check the port isn't blocked by firewall
- Verify the URL is correct
-
API errors
- Check your PluralKit token is valid
- Ensure your system ID is correct
- Verify you have permission to switch fronts
The server logs all important events to the console. For production use, consider setting up proper logging.
- Keep your PluralKit token secure
- Don't commit
config.json
with real tokens to version control - The
.gitignore
file preventsconfig.json
from being committed - Consider using environment variables for production
- The WebSocket server has no authentication - add it if needed for production
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
MIT License - feel free to modify and use as needed.
If you encounter any issues or have questions:
- Check the
commands.txt
file for available commands - Review the server logs for error messages
- Ensure your PluralKit token and system ID are correct
- Verify the WebSocket connection is working properly