feat: add cJSON and SQLite amalgamation source files under deps/
Add the cJSON library (cJSON.c, cJSON.h) and SQLite amalgamation (sqlite3.c, sqlite3.h, sqlite3ext.h, shell.c) as vendored dependencies in the deps/ directory for use by the project build system.
This commit is contained in:
Vendored
+44
@@ -0,0 +1,44 @@
|
||||
// retoor <retoor@molodetz.nl>
|
||||
|
||||
import "websocket" for WebSocketServer
|
||||
|
||||
System.print("=== WebSocket Server Demo ===")
|
||||
System.print("Listening on ws://0.0.0.0:8080\n")
|
||||
|
||||
var server = WebSocketServer.bind("0.0.0.0", 8080)
|
||||
|
||||
while (true) {
|
||||
System.print("Waiting for connection...")
|
||||
var ws = server.accept()
|
||||
|
||||
if (ws == null) {
|
||||
System.print("Failed to accept connection")
|
||||
continue
|
||||
}
|
||||
|
||||
System.print("Client connected")
|
||||
|
||||
while (ws.isOpen) {
|
||||
var msg = ws.receive()
|
||||
|
||||
if (msg == null) {
|
||||
System.print("Connection lost")
|
||||
break
|
||||
}
|
||||
|
||||
if (msg.isClose) {
|
||||
System.print("Client sent close frame (code: %(msg.closeCode))")
|
||||
break
|
||||
}
|
||||
|
||||
if (msg.isText) {
|
||||
System.print("Received text: %(msg.text)")
|
||||
ws.send("Echo: %(msg.text)")
|
||||
} else if (msg.isBinary) {
|
||||
System.print("Received binary: %(msg.bytes.count) bytes")
|
||||
ws.sendBinary(msg.bytes)
|
||||
}
|
||||
}
|
||||
|
||||
System.print("Client disconnected\n")
|
||||
}
|
||||
Reference in New Issue
Block a user