Skip to content

Commit f3eb128

Browse files
committed
feat(docs): add first version of docs
1 parent ce43a23 commit f3eb128

10 files changed

+98
-0
lines changed

Diff for: docs/.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
book

Diff for: docs/book.toml

+6
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
[book]
2+
authors = ["vivax"]
3+
language = "en"
4+
multilingual = false
5+
src = "src"
6+
title = "Twitch-Minimap"

Diff for: docs/src/SUMMARY.md

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Summary
2+
3+
[Introduction](intro.md)
4+
5+
- [Core Api](api.md)
6+
- [Game Side](api_game.md)
7+
- [Extension Side](api_extension.md)
8+
- [Minimap Extension](minimap.md)
9+
- [Api](minimap_api.md)
10+
- [Bevy](minimap_bevy.md)

Diff for: docs/src/api.md

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
# Core Api
2+
3+
The current host of the server is `websocket.matissetec.dev`.
4+
5+
## Targeting minimap extension
6+
7+
If you are targeting the minimap extension check if your engine already has a plugin (under the "Minimap Extension" category), if not the [Game Side](api_game.md) section here and [Api](minimap_api.md) section under the extensions category will be what you need to implement your own game.
8+
9+
## Custom Extension
10+
11+
If you are implementing a custom extension then both of the sub-categories here will be helpful for you.

Diff for: docs/src/api_extension.md

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
# Extension Side
2+
3+
The extension/client should establish a websocket connection to `/lobby/connect?user=123`, where `123` is the user id of the twitch channel the extension is running on.
4+
5+
You will now get any messages sent by the game, and the game will get any messages you send over the connection.
6+
7+
## Example
8+
9+
```js
10+
window.Twitch.ext.onAuthorized((auth) => {
11+
const wsUrl = `wss://${HOST}/lobby/connect?user=${auth.channelId}`;
12+
socket = new WebSocket(wsUrl);
13+
14+
socket.addEventListener("open", function (event) {
15+
console.log("Connected to the WebSocket server");
16+
});
17+
18+
socket.addEventListener("message", function (event) {
19+
let data = JSON.parse(event.data);
20+
console.log(data);
21+
});
22+
})
23+
```
24+

Diff for: docs/src/api_game.md

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# Game Side
2+
3+
First do a post request to `/lobby/new?user=123`, where `123` is the channel id of the lobby that should be created. The body of the request will be a simple plaintext key you should store for the next step.
4+
5+
Establish a websocket connection to `/lobby/connect/streamer?user=123&key=your_key`, where `your_key` is the key you got in the last step. You will now recieve any messages sent by an extension, and the extension will get any messages you send.
6+
7+
For the expected format for the minimap extension see [Minimap Api](minimap_api.md)

Diff for: docs/src/intro.md

+4
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
# Twitch Minimap
2+
3+
This project is at its core a websocket proxy server, and a twitch minimap extension.
4+
The server works independently from the extension and can be used to facilitate other types of extensions as well.

Diff for: docs/src/minimap.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Minimap Extension
2+
3+
If you are writing a game targeting the extension then check out the page for your engine, or [Api](minimap_api.md) if you need to implement it yourself.

Diff for: docs/src/minimap_api.md

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# Api
2+
3+
## Game to Extension
4+
5+
### Css
6+
7+
format: `{"data": {"css": "..."}}`.
8+
9+
where the `css` key holds a css string that will be injected into the page.
10+
Every time this event is recieved from the extension the previous css will be replaced.
11+
12+
### Units
13+
14+
messagge format: `{"data": [...]}`.
15+
16+
unit format: `{"id": "1234", "kind": "Sphere", "x": 0.34, "y": 0.35}`
17+
* `id`: This is a unique id for the entity, this is also added as a css class to the entity in the format of `_id` (i.e in the example above it would be `_1234`)
18+
* `kind`: This is a css class that will be added to the entity and is a nice way to reuse css across multiple entities,
19+
* `x` & `y`: these are the positions of the entities, in the range 0-1. 0,0 being in the top left.
20+
21+
## Extension to Game
22+
23+
### Click
24+
format: `{"x": 0.34, "y": 0.12, "userId": "12312", "bubbleColor": "#00ff00", "bubbleSize": 0.23, "itemType": "Random"}`
25+
* `x` & `y`: position of the click in range 0-1, 0,0 in top left.
26+
* `userId`: twitch id of the user who clicked
27+
* `bubbleColor`: The user selected color
28+
* `bubbleSize`: The user selected size
29+
* `itemType`: User selected item, one of `Random`, `Sphere`, `Cube`

Diff for: docs/src/minimap_bevy.md

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# Bevy
2+
3+
See: <https://docs.rs/bevy_twitch_minimap/>

0 commit comments

Comments
 (0)