Compare commits
4 commits
cbaef0c7a0
...
9111c63691
Author | SHA1 | Date | |
---|---|---|---|
9111c63691 | |||
9af8f7d3d6 | |||
1f28c7cbba | |||
94cda49a16 |
4 changed files with 60 additions and 18 deletions
|
@ -18,10 +18,11 @@ You can send raw text to the WS server. This text is in form of commands:
|
||||||
- `MSG {token} {message}` will set the message and broadcast it to all logged-in clients;
|
- `MSG {token} {message}` will set the message and broadcast it to all logged-in clients;
|
||||||
- `CLEAR {token}` will clear the current message.
|
- `CLEAR {token}` will clear the current message.
|
||||||
|
|
||||||
You may receive one of two packets while using the server:
|
You may receive one of three responses while using the server:
|
||||||
|
|
||||||
- `MSG {message}` to indicate there's a new message. The client should react by showing an alert with the message. If no message is present, the packet will be `MSG` only. In this case, the client shouldn't react.
|
- `MSG {message}` to indicate there's a new message. The client should react by showing an alert with the message. If no message is present, the packet will be `MSG` only. In this case, the client shouldn't react.
|
||||||
- `OK` indicates the action was successful. The client should react by showing an alert telling the user so.
|
- `OK` indicates the action was successful. The client should react by showing an alert telling the user so.
|
||||||
|
- `NULL` to indicate that no data is available. No client reaction is intended.
|
||||||
|
|
||||||
## Frontend
|
## Frontend
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@
|
||||||
<head>
|
<head>
|
||||||
<meta charset="UTF-8">
|
<meta charset="UTF-8">
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<title>HTML 5 Boilerplate</title>
|
<title>Vencord EAS</title>
|
||||||
<link href="https://cdn.jsdelivr.net/npm/beercss@3.5.8/dist/cdn/beer.min.css" rel="stylesheet">
|
<link href="https://cdn.jsdelivr.net/npm/beercss@3.5.8/dist/cdn/beer.min.css" rel="stylesheet">
|
||||||
|
|
||||||
<script type="module" src="https://cdn.jsdelivr.net/npm/beercss@3.5.8/dist/cdn/beer.min.js"></script>
|
<script type="module" src="https://cdn.jsdelivr.net/npm/beercss@3.5.8/dist/cdn/beer.min.js"></script>
|
||||||
|
@ -19,31 +19,27 @@
|
||||||
<h3>Vencord EAS Client</h3>
|
<h3>Vencord EAS Client</h3>
|
||||||
<div class="field suffix border" style="margin-bottom: 0px;">
|
<div class="field suffix border" style="margin-bottom: 0px;">
|
||||||
<select id="endpoint">
|
<select id="endpoint">
|
||||||
<option>Get message</option>
|
<option value="get">Get message</option>
|
||||||
<option>🔑 Send message</option>
|
<option value="msg">🔑 Send message</option>
|
||||||
<option>🔑 Clear message</option>
|
<option value="clear">🔑 Clear message</option>
|
||||||
</select>
|
</select>
|
||||||
<i>arrow_drop_down</i>
|
<i>arrow_drop_down</i>
|
||||||
</div>
|
</div>
|
||||||
<div class="field label border" style="margin-top: 5px; margin-bottom: 0px;">
|
<div class="field label border" style="margin-top: 5px; margin-bottom: 0px;">
|
||||||
<input type="password">
|
<input type="password" id="token">
|
||||||
<label>Token (if needed)</label>
|
<label>Token (if needed)</label>
|
||||||
</div>
|
</div>
|
||||||
<div class="field label border" style="margin-top: 5px; margin-bottom: 10px;">
|
<div class="field label border" style="margin-top: 5px; margin-bottom: 10px;">
|
||||||
<input type="text">
|
<input type="text" id="msg">
|
||||||
<label>Message (if needed)</label>
|
<label>Message (if needed)</label>
|
||||||
</div>
|
</div>
|
||||||
<button class="responsive" style="margin-bottom: 20px;">
|
<button class="responsive" onclick="processSend()" style="margin-bottom: 20px;">
|
||||||
<i>rocket</i>
|
<i>rocket</i>
|
||||||
<span>Send</span>
|
<span>Send</span>
|
||||||
</button>
|
</button>
|
||||||
<hr>
|
<hr>
|
||||||
<div class="field textarea label border">
|
<h6>Logs</h6>
|
||||||
<textarea readonly style="width: 100%;" id="log"></textarea>
|
<p id="log"></p>
|
||||||
<label>Logs</label>
|
<script src="index.js"></script>
|
||||||
</div>
|
|
||||||
<script>
|
|
||||||
|
|
||||||
</script>
|
|
||||||
</body>
|
</body>
|
||||||
</html>
|
</html>
|
42
front/index.js
Normal file
42
front/index.js
Normal file
|
@ -0,0 +1,42 @@
|
||||||
|
const socket = new WebSocket('wss://eas-ws.nin0.dev');
|
||||||
|
|
||||||
|
socket.onopen = function(event) {
|
||||||
|
log("Connection opened")
|
||||||
|
};
|
||||||
|
|
||||||
|
socket.onmessage = function(event) {
|
||||||
|
log("IN: " + event.data)
|
||||||
|
if(event.data.startsWith("MSG ")) {
|
||||||
|
alert(event.data.replace("MSG ", ""))
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
socket.onclose = function(event) {
|
||||||
|
alert("Connection has been closed, refresh the page.");
|
||||||
|
};
|
||||||
|
|
||||||
|
function sendMessage(message) {
|
||||||
|
socket.send(message);
|
||||||
|
log("OUT: " + message)
|
||||||
|
}
|
||||||
|
|
||||||
|
function log(message) {
|
||||||
|
const logArea = document.getElementById("log");
|
||||||
|
const newVal = message + "<br/>" + logArea.innerHTML;
|
||||||
|
logArea.innerHTML = newVal;
|
||||||
|
}
|
||||||
|
|
||||||
|
function processSend() {
|
||||||
|
const endpoint = document.getElementById("endpoint").value
|
||||||
|
if(endpoint == "get") {
|
||||||
|
sendMessage("GET")
|
||||||
|
}
|
||||||
|
const token = document.getElementById("token").value
|
||||||
|
const msg = document.getElementById("msg").value
|
||||||
|
if(endpoint == "msg") {
|
||||||
|
sendMessage(`MSG ${token} ${msg}`)
|
||||||
|
}
|
||||||
|
if(endpoint == "clear") {
|
||||||
|
sendMessage(`CLEAR ${token}`)
|
||||||
|
}
|
||||||
|
}
|
5
main.py
5
main.py
|
@ -18,12 +18,15 @@ async def handle(websocket):
|
||||||
CONNECTIONS.add(websocket)
|
CONNECTIONS.add(websocket)
|
||||||
async for message in websocket:
|
async for message in websocket:
|
||||||
if message == "GET":
|
if message == "GET":
|
||||||
|
if EAS_MESSAGE == "":
|
||||||
|
await websocket.send("NULL")
|
||||||
|
return
|
||||||
await websocket.send(f"MSG {EAS_MESSAGE}")
|
await websocket.send(f"MSG {EAS_MESSAGE}")
|
||||||
if message.startswith(f"MSG {TOKEN} "):
|
if message.startswith(f"MSG {TOKEN} "):
|
||||||
# broadcast from vee
|
# broadcast from vee
|
||||||
EAS_MESSAGE = message.replace(f"MSG {TOKEN} ", "")
|
EAS_MESSAGE = message.replace(f"MSG {TOKEN} ", "")
|
||||||
websockets.broadcast(CONNECTIONS, f"MSG {EAS_MESSAGE}")
|
websockets.broadcast(CONNECTIONS, f"MSG {EAS_MESSAGE}")
|
||||||
if message.startswith(f"CLEAR {TOKEN} "):
|
if message.startswith(f"CLEAR {TOKEN}"):
|
||||||
# clear
|
# clear
|
||||||
EAS_MESSAGE = ""
|
EAS_MESSAGE = ""
|
||||||
await websocket.send(f"OK")
|
await websocket.send(f"OK")
|
||||||
|
|
Reference in a new issue