Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
122 changes: 92 additions & 30 deletions content/2.docs4devs/9.netplay.md
Original file line number Diff line number Diff line change
@@ -1,46 +1,108 @@
# Netplay
# EmulatorJS Netplay Server Setup Guide

The old version of netplay that works versions prior to 4.0 (version 3.0) is really buggy and not recommended unless you need to.
Step-by-step instructions to set up your own EmulatorJS netplay server.

::alert{type="danger"}
::list{type="danger"}
- Netplay is currently **not supported**. Any bugs will not be fixed. A netplay re-write is being worked on.
::
::
## Prerequisites

## To add to your site
Before beginning ensure you have a netplay server to use or host your own.

1. Set a game id in the javascript config
```js
EJS_gameID = 1; //Id needs to be unique per game in your website!
```
## Server Setup

The EmulatorJS Netplay server is maintained in a separate repository.
Go clone the repository and follow its instructions:

2. At the moment, netplay requires the old cores. To do this you must add this line to your code.
```js
EJS_oldCores = true;
```bash
git clone https://github.com/EmulatorJS/EmulatorJS-Netplay.git
cd EmulatorJS-Netplay
```

**These 2 steps will add netplay to your website!**
> Follow the README in the repository for installation and running instructions.

---

## To host your own server:
## Website Integration

1. Clone the EmulatorJS-netplay repository
```sh
git clone https://github.com/EmulatorJS/EmulatorJS-netplay-old.git
In your JavaScript configuration file:

1. **Set a Unique Game ID**

```javascript
EJS_gameID = 1; // Must be unique per game on your website
```

2. Install nodejs dependencies
```sh
npm install
2. **Configure Server Settings**

> Add or remove ICE servers as needed for your specific requirements.
> These are just examples of free, open-source servers.

```javascript
EJS_netplayServer: 'https://yourIP:port#',
EJS_netplayICEServers: [
{ urls: 'stun:stun.l.google.com:19302' },
{ urls: 'stun:stun1.l.google.com:19302' },
{ urls: 'stun:stun2.l.google.com:19302' },
{ urls: 'stun:stun.nextcloud.com:3478' },
{ urls: 'turn:openrelay.metered.ca:80', username: 'openrelayproject', credential: 'openrelayproject' },
{ urls: 'turn:openrelay.metered.ca:443', username: 'openrelayproject', credential: 'openrelayproject' }
]
```

3. start the server
```sh
npm run start
> You can visit https://developer.mozilla.org/en-US/docs/Web/API/WebRTC_API/Protocols for more information on what these servers are used for.

---

## Sharing Your Server

To allow friends to connect to your server over the internet, you need to configure your firewall and router.

### Firewall Configuration

#### Windows
1. Search for **"Windows Defender Firewall with Advanced Security"**
2. Navigate to **"Inbound Rules"**
3. Click **"New Rule..."**
4. Select **"Port"** and follow prompts to allow TCP traffic for the port used by your server (default **3000**)

#### Linux (using ufw)

```bash
sudo ufw allow 3000/tcp
```

You can then set your netplay server with the `EJS_netplayUrl` setting.
```js
EJS_netplayUrl = "URL HERE";
### Port Forwarding

1. **Find Your Local IP Address**
- **Windows:** Run `ipconfig` in Command Prompt, look for "IPv4 Address"
- **Linux:** Run `hostname -I` in terminal

2. **Access Router Admin Panel**
- Open web browser and navigate to your router admin page

3. **Configure Port Forwarding**
- Create a rule with these settings:
- **Application Name:** Netplay Server
- **External/Start Port:** 3000
- **Internal/End Port:** 3000
- **Protocol:** TCP
- **Device IP:** Your computer's local IP address

### Share Connection Details

1. **Find Your Public IP**
- Google search: "what is my IP"
- Copy the displayed IP address

2. **Give the Connection Details to Friends**
- Format: `[Your Public IP]:3000`
- Example: `123.45.67.89:3000`

---

## Troubleshooting

- Ensure Node.js is installed
- Verify firewall rules are correctly configured
- Check that port forwarding is set up on your router
- Confirm your public IP address is current
- Make sure the server is running before attempting connections
```
<!-- EJS_netplayServer -->