mirror of
https://github.com/JustKato/FreePad.git
synced 2026-03-23 20:39:45 +02:00
* Some code notes
This commit is contained in:
@@ -11,10 +11,11 @@ import (
|
|||||||
)
|
)
|
||||||
|
|
||||||
var wsUpgrader = websocket.Upgrader{
|
var wsUpgrader = websocket.Upgrader{
|
||||||
ReadBufferSize: 1024,
|
ReadBufferSize: 1024, // TODO: Make it configurable via the .env file
|
||||||
WriteBufferSize: 1024,
|
WriteBufferSize: 1024, // TODO: Make it configurable via the .env file
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Use generics so that we can take string messages, that'd be nice!
|
||||||
type SocketMessage struct {
|
type SocketMessage struct {
|
||||||
EventType string `json:"eventType"`
|
EventType string `json:"eventType"`
|
||||||
PadName string `json:"padName"`
|
PadName string `json:"padName"`
|
||||||
|
|||||||
@@ -2,6 +2,9 @@ class PadSocket {
|
|||||||
|
|
||||||
ws = null;
|
ws = null;
|
||||||
padName = null;
|
padName = null;
|
||||||
|
/**
|
||||||
|
* @deprecated
|
||||||
|
*/
|
||||||
state = null;
|
state = null;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -20,6 +23,7 @@ class PadSocket {
|
|||||||
// Connect to the websocket
|
// Connect to the websocket
|
||||||
const ws = new WebSocket(connUrl);
|
const ws = new WebSocket(connUrl);
|
||||||
ws.onopen = () => {
|
ws.onopen = () => {
|
||||||
|
// TODO: This is redundant, we could check the websocket status: ws.readyState == WebSocket.OPEN
|
||||||
this.state = 'active';
|
this.state = 'active';
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -51,6 +55,7 @@ class PadSocket {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Compress the message, usually we will be sending the whole body of the pad from the client to the server or vice-versa.
|
||||||
this.ws.send( JSON.stringify({
|
this.ws.send( JSON.stringify({
|
||||||
eventType,
|
eventType,
|
||||||
padName: this.padName,
|
padName: this.padName,
|
||||||
@@ -65,6 +70,7 @@ class PadSocket {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// TODO: Test if this is actually necessary or the DOMContentLoaded event would suffice
|
||||||
// wait for the whole window to load
|
// wait for the whole window to load
|
||||||
window.addEventListener(`load`, e => {
|
window.addEventListener(`load`, e => {
|
||||||
window.socket = new PadSocket(padTitle);
|
window.socket = new PadSocket(padTitle);
|
||||||
|
|||||||
Reference in New Issue
Block a user