Browse code

[add] doc

Christian FraƟ authored on19/11/2021 13:01:30
Showing1 changed files
1 1
new file mode 100644
... ...
@@ -0,0 +1,50 @@
1
+## Usage
2
+
3
+Simply file an HTTP request to the server with:
4
+
5
+- method: `POST` (or any other, that accepts a body)
6
+- body: JSON encoded data of type `record<id:(null|string),action:string,data:any>`, where:
7
+	- `id` is the connection identifier
8
+	- `action` is the name of the action to execute
9
+	- `data` is the data for the action; its concrete structure is described as the input type of the action
10
+
11
+Example: `curl 'http://localhost:7979' -d '{"id":"foo1bar2",action":"send","data":{"channel":"#main","message":"hello"}}'`
12
+
13
+
14
+## Actions
15
+
16
+### `connect`
17
+
18
+- description: starts to establish a connection and returns the connection identifier
19
+- input type: `record<server:string,nickname:string,channels:list<string>>`
20
+- output type: `integer`
21
+
22
+
23
+### `disconnect`
24
+
25
+- description: ends an established connection
26
+- input type: `void`
27
+- output type: `void`
28
+
29
+
30
+### `check`
31
+
32
+- description: checks if the connection is established
33
+- input type: `void`
34
+- output type: `boolean`
35
+
36
+
37
+### `send`
38
+
39
+- description: sends a message
40
+- input type: `record<channel:string,message:string>`
41
+- output type: `void`
42
+
43
+
44
+### `fetch`
45
+
46
+- description: gets the current user list and all new (since the last call) events
47
+- input type: `void`
48
+- output type: `record<users:list<record<name:string,role:string>>,events:list<record<timestamp:integer,kind:string,data:map<string,any>>>>`
49
+
50
+