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
+7
@@ -0,0 +1,7 @@
|
||||
import "websocket" for WebSocket
|
||||
|
||||
var accept = WebSocket.computeAcceptKey_("dGhlIHNhbXBsZSBub25jZQ==")
|
||||
System.print(accept) // expect: s3pPLMBiTxaQ9kYGzzhZRbK+xOo=
|
||||
|
||||
var accept2 = WebSocket.computeAcceptKey_("x3JJHMbDL1EzLkh9GBhXDw==")
|
||||
System.print(accept2) // expect: HSmrc0sMlYUkAGmm5OPpG2HaGWk=
|
||||
Vendored
+34
@@ -0,0 +1,34 @@
|
||||
import "websocket" for WebSocketMessage
|
||||
|
||||
var text = WebSocketMessage.new_(1, [72, 101, 108, 108, 111], true)
|
||||
System.print(text.opcode) // expect: 1
|
||||
System.print(text.isText) // expect: true
|
||||
System.print(text.isBinary) // expect: false
|
||||
System.print(text.isClose) // expect: false
|
||||
System.print(text.isPing) // expect: false
|
||||
System.print(text.isPong) // expect: false
|
||||
System.print(text.text) // expect: Hello
|
||||
System.print(text.bytes) // expect: [72, 101, 108, 108, 111]
|
||||
|
||||
var binary = WebSocketMessage.new_(2, [1, 2, 3, 4], true)
|
||||
System.print(binary.opcode) // expect: 2
|
||||
System.print(binary.isText) // expect: false
|
||||
System.print(binary.isBinary) // expect: true
|
||||
System.print(binary.bytes) // expect: [1, 2, 3, 4]
|
||||
|
||||
var close = WebSocketMessage.new_(8, [3, 232], true)
|
||||
System.print(close.opcode) // expect: 8
|
||||
System.print(close.isClose) // expect: true
|
||||
System.print(close.closeCode) // expect: 1000
|
||||
|
||||
var closeWithReason = WebSocketMessage.new_(8, [3, 232, 98, 121, 101], true)
|
||||
System.print(closeWithReason.closeCode) // expect: 1000
|
||||
System.print(closeWithReason.closeReason) // expect: bye
|
||||
|
||||
var ping = WebSocketMessage.new_(9, [], true)
|
||||
System.print(ping.isPing) // expect: true
|
||||
System.print(ping.isPong) // expect: false
|
||||
|
||||
var pong = WebSocketMessage.new_(10, [], true)
|
||||
System.print(pong.isPing) // expect: false
|
||||
System.print(pong.isPong) // expect: true
|
||||
Vendored
+52
@@ -0,0 +1,52 @@
|
||||
import "websocket" for WebSocket, WebSocketServer
|
||||
import "scheduler" for Scheduler
|
||||
import "timer" for Timer
|
||||
|
||||
var testResults = []
|
||||
var port = 19876
|
||||
|
||||
Scheduler.add {
|
||||
var server = WebSocketServer.bind("127.0.0.1", port)
|
||||
var ws = server.accept()
|
||||
if (ws != null) {
|
||||
var msg = ws.receive()
|
||||
if (msg != null && msg.isText) {
|
||||
testResults.add("server:" + msg.text)
|
||||
ws.send("pong:" + msg.text)
|
||||
}
|
||||
msg = ws.receive()
|
||||
if (msg != null && msg.isBinary) {
|
||||
testResults.add("server_binary:" + msg.bytes.count.toString)
|
||||
ws.sendBinary(msg.bytes)
|
||||
}
|
||||
ws.close()
|
||||
}
|
||||
server.close()
|
||||
}
|
||||
|
||||
Timer.sleep(50)
|
||||
|
||||
Scheduler.add {
|
||||
var ws = WebSocket.connect("ws://127.0.0.1:%(port)")
|
||||
ws.send("ping")
|
||||
var msg = ws.receive()
|
||||
if (msg != null && msg.isText) {
|
||||
testResults.add("client:" + msg.text)
|
||||
}
|
||||
ws.sendBinary([1, 2, 3, 4, 5])
|
||||
msg = ws.receive()
|
||||
if (msg != null && msg.isBinary) {
|
||||
testResults.add("client_binary:" + msg.bytes.count.toString)
|
||||
}
|
||||
ws.close()
|
||||
}
|
||||
|
||||
Timer.sleep(200)
|
||||
|
||||
for (r in testResults) {
|
||||
System.print(r)
|
||||
}
|
||||
// expect: server:ping
|
||||
// expect: client:pong:ping
|
||||
// expect: server_binary:5
|
||||
// expect: client_binary:5
|
||||
Reference in New Issue
Block a user