WordPress plugin that provides multiplayer functionality for the Jackalopes FPS game.
Jackalopes Server is a WordPress plugin that implements a WebSocket server to enable real-time multiplayer gameplay for the Jackalopes FPS game. It handles player connections, game sessions, and state synchronization.
- Add the repository to your
composer.json
file:
"repositories": [
{
"type": "vcs",
"url": "https://github.com/yourusername/jackalopes-server"
}
]
- Require the package:
composer require jackalopes/jackalopes-server
- Activate the plugin in WordPress admin.
- Download the plugin zip file.
- Upload to your WordPress plugins directory.
- Run
composer install
within the plugin directory to install dependencies. - Activate the plugin in WordPress admin.
The plugin comes with a bundled Node.js binary to eliminate external dependencies. This ensures the server can run without requiring Node.js to be installed on the host system.
After installing the plugin for the first time, run the setup script to download the appropriate Node.js binary for your server's architecture:
cd web/app/plugins/jackalopes-server && ./bin/setup-node.sh
This script will:
- Detect your server's OS and architecture
- Download the appropriate Node.js binary
- Make it executable and configure it for the plugin
If you've included the Node.js binary in your git repository (as configured in .gitignore
), you won't need to perform any additional steps during deployment.
If you encounter permissions issues, you may need to set executable permissions:
chmod +x web/app/plugins/jackalopes-server/bin/node
chmod +x web/app/plugins/jackalopes-server/bin/npm
For proper WebSocket connectivity, you need to configure your web server (Nginx/Apache) with a proxy to forward WebSocket connections. Here's how to set it up:
Add this to your server block configuration:
# WebSocket proxy for Jackalopes Server
location /websocket/ {
proxy_pass http://localhost:8082;
proxy_http_version 1.1;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_set_header X-Forwarded-Proto $scheme;
proxy_read_timeout 86400; # 24 hours
proxy_buffering off;
}
In your game client, use the following WebSocket URL:
ws://yourdomain.com/websocket/
Note the trailing slash - it's required for the proper routing of WebSocket connections.
We plan to further automate the server setup process:
- WordPress Activation Hook: Add an activation hook that automatically runs the Node.js setup script when the plugin is activated
- Deployment Integration: Implement integration with common deployment tools (Trellis, Capistrano, etc.) to handle binary setup
- Self-Healing: Add monitoring and self-repair functionality to restart the server if it stops
- Auto-Update: Develop a system to automatically update the Node.js binary to the latest LTS version
- Multi-environment Configuration: Provide easy configuration for different environments (development, staging, production)
These improvements will reduce manual steps and ensure the server runs smoothly across different environments.
After installation:
- Navigate to "Jackalopes" in the WordPress admin menu.
- Visit the "Settings" page to configure the WebSocket server:
- Set the desired port (default: 8080)
- Configure maximum connections
- Enable auto-start if needed
- Set logging level
- Go to the Jackalopes Dashboard in WordPress admin.
- Click "Start Server" to start the WebSocket server.
Use the admin interface to stop or restart the server. If you need to manually stop leftover Node processes:
ps aux | grep node
kill [PID]
Use the following WebSocket URL format to connect from your game client:
ws://your-wordpress-site.com/websocket/
The plugin provides the following REST API endpoints:
GET /wp-json/jackalopes/v1/status
- Get server statusGET /wp-json/jackalopes/v1/sessions
- List active game sessionsPOST /wp-json/jackalopes/v1/sessions
- Create a new game sessionPOST /wp-json/jackalopes/v1/sessions/{session_key}/join
- Join an existing session
If you encounter issues:
- Check the plugin logs at
web/app/plugins/jackalopes-server/plugin.log
- Check the server logs at
web/app/plugins/jackalopes-server/server.log
- Verify permissions on the Node.js binary (
bin/node
should be executable) - Check if the port is already in use by another application
GPL-2.0-or-later