aboutsummaryrefslogtreecommitdiff
path: root/docs/Code Documentation/SocketIO.md
diff options
context:
space:
mode:
authorJakob Stendahl <jakob.stendahl@outlook.com>2021-09-19 19:43:11 +0200
committerJakob Stendahl <jakob.stendahl@outlook.com>2021-09-19 19:43:11 +0200
commit7bdce37fd3f18e2712e18c4e2c64cac69af0aca1 (patch)
treeb7ad3f1cca92e2dfd2664ae9e65652bd03ff58b2 /docs/Code Documentation/SocketIO.md
parente6880cd8ccf82d993f222cb14b4860581654acb8 (diff)
downloadLuxcena-Neo-7bdce37fd3f18e2712e18c4e2c64cac69af0aca1.tar.gz
Luxcena-Neo-7bdce37fd3f18e2712e18c4e2c64cac69af0aca1.zip
:boom: Introduce new UI based on svelte, and rewrite a lot of the node app and the NeoRuntime
Diffstat (limited to 'docs/Code Documentation/SocketIO.md')
-rw-r--r--docs/Code Documentation/SocketIO.md116
1 files changed, 116 insertions, 0 deletions
diff --git a/docs/Code Documentation/SocketIO.md b/docs/Code Documentation/SocketIO.md
new file mode 100644
index 0000000..b605857
--- /dev/null
+++ b/docs/Code Documentation/SocketIO.md
@@ -0,0 +1,116 @@
+# SocketIO
+
+## Client
+Socketio is setup in the file `globals`.
+This means, import `globals`, and then you can use `Socket` from there.
+
+### Connect
+1. Client first needs to get an Authentication token,
+ this can be obtained by doing this:
+ ```javascript
+ import {setCookie} from "../../../cookies";
+ let CryptoJS = require("crypto-js");
+ let passwordHash = CryptoJS.SHA256(<PASSWORD>;).toString();
+
+ Socket.emit("authenticate", <USERNAME>, passwordHash, (token) => {
+ // Token will be a string if username/password combo is right,
+ // if not, it is false.
+ setCookie("session_token", token, 500);
+ };)
+ ```
+2. Then the user can authenticate like this:
+ ```javascript
+ import {getCookie} from "../../../cookies";
+ let cookieToken = getCookie("session_token");
+
+ Socket.emit("authenticateToken", cookieToken, (res) => {
+ // Res is true if we got authenticated,
+ // If not, it is false.
+ });
+ ```
+3. We are now authenticated, and all actions and events are available to the client.
+
+### "Actions"
+```javascript
+Socket.emit(Action, *Arguments, (Return) => {
+};)
+```
+
+##### NeoRuntime/status
+
+
+| Name | Type | Description |
+| ------ | ------ | ----------- |
+| status | object | |
+
+??? info "Return/status"
+
+ | Name | Type | Description |
+ | -------------- | ------- | ----------------------------- |
+ | currentScript | string | "None"/Name of current script |
+ | scriptIsExited | boolean | |
+ | uptime | number | |
+
+##### NeoRuntime/Script/Create
+
+??? info "Arguments"
+
+ | Name | Type | Description |
+ | ---------- | ------ | ------------------------------------- |
+ | scriptPath | string | Path of the new script, local/example |
+
+??? info "Return"
+
+ | Name | Type | Description |
+ | ------ | ------- | --------------------- |
+ | res | boolean | success |
+ | resMsg | string | if fail, errorMessage |
+
+
+##### NeoRuntime/Script/Delete
+
+??? info "Arguments"
+
+ | Name | Type | Description |
+ | ---------- | ------ | ------------------------------------------- |
+ | scriptPath | string | Path of the script to delete, local/example |
+
+??? info "Return"
+
+ | Name | Type | Description |
+ | ------ | ------- | --------------------- |
+ | res | boolean | success |
+ | resMsg | string | if fail, errorMessage |
+
+##### NeoRuntime/Script/Select
+
+??? info "Arguments"
+
+ | Name | Type | Description |
+ | ---------- | ------ | ------------------------------------------ |
+ | scriptPath | string | Path of the script to start, local/example |
+
+##### NeoRuntime/Scripts/get
+
+??? info "Return"
+
+ | Name | Type | Description |
+ | ------ | ------- | --------------------- |
+ | local | list | local scripts |
+ | remote | list | remote scripts |
+
+### "Events"
+```javascript
+// Listen for a event
+Socket.emit(event + "::join");
+Socket.on(event, (*Return); => {
+
+})
+```
+```javascript
+// Stop listening for an event
+Socket.emit(event + "::leave")
+```
+
+
+## Server