@vinceau/slp-wii-connect
v1.0.2
Published
Library for connecting to the Slippi Wii network interface
Downloads
16
Maintainers
Readme
slp-wii-connect
Extract raw Slippi data directly from the console or from a Slippi relay
Table of Contents
Installation
With NPM
npm install @vinceau/slp-wii-connect
With Yarn
yarn add @vinceau/slp-wii-connect
Usage
const { ConsoleConnection } = require("@vinceau/slp-wii-connect");
const connection = new ConsoleConnection();
connection.connect("133.221.123.111", 1667);
connection.on("data", (data) => {
// Received data from console
console.log(data);
});
connection.on("statusChange", (status) => {
console.log(`status changed: ${status}`);
});
API
Methods
connect(ip, port, [timeout])
Attempt connection to a Wii or Slippi relay.
ip
The IP address to connect to.
- Required:
true
- Type:
string
port
The port to connect through.
- Required:
true
- Type:
number
[timeout]
The milliseconds to wait before a connection attempt fails.
- Required:
false
- Type:
number
disconnect()
Terminates the existing connection.
getStatus()
Returns ConnectionStatus
.
getSettings()
Returns ConnectionSettings
.
getDetails()
Returns ConnectionDetails
.
Events
You can subscribe to the following events using the connection.on()
method. For example:
connection.on("data", (data) => {
console.log(`Got the following data: ${data}`);
});
data
(data: Uint8Array) => void
Emitted when game data is received.
handshake
(details: ConnectionDetails) => void
Emitted for all handshake messages.
statusChange
(status: ConnectionStatus) => void
Emitted whenever the connection status changes.
Types
ConnectionSettings
| Key | Type |
| ----------- | ------ |
| ipAddress
| string |
| port
| number |
ConnectionDetails
| Key | Type |
| ----------------- | ---------- |
| consoleNickname
| string |
| gameDataCursor
| Uint8Array |
| version
| string |
| clientToken
| number |
ConnectionStatus
A number representing the current connection status. Possible values are as follows:
| Value | Status | | ------ | ------------- | | 0 | Disconnected | | 1 | Connecting | | 2 | Connected | | 3 | Reconnecting |
Development
To build the library from source:
yarn run build
To start the development server:
yarn run watch
Acknowledgements
This library is largely taken from code available in the slippi-desktop-app
. Credits to Jas Laferriere and the rest of the Project Slippi team.
License
This software is released under the terms of LGPL-3.0 license.