From f5c4671bfbad96bf346bd7e9a21fc4317b4959df Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Sat, 3 Dec 2022 17:00:20 +0530 Subject: Adds most of the tools --- .../net/websocket/tests/autobahn/autobahn_client.v | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 v_windows/v/vlib/net/websocket/tests/autobahn/autobahn_client.v (limited to 'v_windows/v/vlib/net/websocket/tests/autobahn/autobahn_client.v') diff --git a/v_windows/v/vlib/net/websocket/tests/autobahn/autobahn_client.v b/v_windows/v/vlib/net/websocket/tests/autobahn/autobahn_client.v new file mode 100644 index 0000000..c65fdab --- /dev/null +++ b/v_windows/v/vlib/net/websocket/tests/autobahn/autobahn_client.v @@ -0,0 +1,33 @@ +// use this test to test the websocket client in the autobahn test +module main + +import net.websocket + +fn main() { + for i in 1 .. 304 { + println('\ncase: $i') + handle_case(i) or { println('error should be ok: $err') } + } + // update the reports + uri := 'ws://autobahn_server:9001/updateReports?agent=v-client' + mut ws := websocket.new_client(uri) ? + ws.connect() ? + ws.listen() ? +} + +fn handle_case(case_nr int) ? { + uri := 'ws://autobahn_server:9001/runCase?case=$case_nr&agent=v-client' + mut ws := websocket.new_client(uri) ? + ws.on_message(on_message) + ws.connect() ? + ws.listen() ? +} + +fn on_message(mut ws websocket.Client, msg &websocket.Message) ? { + // autobahn tests expects to send same message back + if msg.opcode == .pong { + // We just wanna pass text and binary message back to autobahn + return + } + ws.write(msg.payload, msg.opcode) or { panic(err) } +} -- cgit v1.2.3