1.0.2 • Published 4 years ago

@vinceau/slp-wii-connect v1.0.2

Weekly downloads
1
License
LGPL-3.0-or-later
Repository
github
Last release
4 years ago

slp-wii-connect

npm version Build Status

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

KeyType
ipAddressstring
portnumber

ConnectionDetails

KeyType
consoleNicknamestring
gameDataCursorUint8Array
versionstring
clientTokennumber

ConnectionStatus

A number representing the current connection status. Possible values are as follows:

ValueStatus
0Disconnected
1Connecting
2Connected
3Reconnecting

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.

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

5 years ago