-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
20 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,42 @@ | ||
# Archipelago.js | ||
![GitHub](https://img.shields.io/github/license/thephar/archipelago.js?style=flat-square) ![GitHub package.json version](https://img.shields.io/github/package-json/v/thephar/archipelago.js?style=flat-square) ![GitHub repo size](https://img.shields.io/github/repo-size/thephar/archipelago.js?style=flat-square) ![Discord](https://img.shields.io/discord/731205301247803413?label=discord&style=flat-square) | ||
![GitHub](https://img.shields.io/github/license/thephar/archipelago.js?style=flat-square) | ||
![npm](https://img.shields.io/npm/v/archipelago.js?style=flat-square) | ||
![npm type definitions](https://img.shields.io/npm/types/archipelago.js?style=flat-square) | ||
![npm](https://img.shields.io/npm/dm/archipelago.js?style=flat-square) | ||
|
||
A general purpose library for communicating with Archipelago servers via Node.js. | ||
|
||
## Getting Started | ||
|
||
```javascript | ||
import { ArchipelagoClient, NetworkVersion, SayPacket } from "archipelago.js"; | ||
import { ArchipelagoClient, NetworkVersion } from "archipelago.js"; | ||
|
||
// Set up our client. | ||
const version = new NetworkVersion(0, 3, 2); | ||
const client = new ArchipelagoClient("10.0.0.92:38281", version); | ||
|
||
// Connect to the AP server and log in. | ||
client.connect("CC", "Phar") | ||
// Send packets! | ||
.then(() => client.send(new SayPacket("Hello, world!"))) | ||
// Connect to the Archipelago server! | ||
client | ||
.connect("Archipelago", "Test") | ||
.then(() => { | ||
// Send a client packet! | ||
client.send({ cmd: "Say", text: "Hello world!" }); | ||
}) | ||
.catch(console.error); | ||
|
||
// Listen for packets. | ||
client.addListener("packetReceived", (packet) => { | ||
console.log(packet); | ||
// Listen for events! | ||
client.addListener("print", (packet) => { | ||
console.log(packet.text); | ||
}); | ||
``` | ||
|
||
The `ArchipelagoClient` handles all the main interactions with the Archipelago server, including sending and receiving packets and maintaining the websocket connection. | ||
|
||
Currently, there are no helper functions to assist in most tasks, so a lot of the functionality still requires manual listening to certain packets and handling them accordingly. | ||
The `ArchipelagoClient` handles all the main interactions with the Archipelago server, including sending and receiving | ||
packets and maintaining the websocket connection. | ||
|
||
This library is still in development so more features will be coming to make developing with this library easier. | ||
|
||
### Written in TypeScript | ||
|
||
This application was written in TypeScript and thus has access to all the type information of each packet and its parts. You can still load this application in vanilla JavaScript if you prefer, though and still have access to type information. | ||
This application was written in TypeScript and thus has access to all the type information of each packet and its parts. | ||
You can still load this application in vanilla JavaScript if you prefer, though and still have access to type | ||
information. |