-
Notifications
You must be signed in to change notification settings - Fork 13
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Jianhui Zhao <zhaojh329@gmail.com>
- Loading branch information
Showing
4 changed files
with
151 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env eco | ||
|
||
local websocket = require 'eco.websocket' | ||
|
||
local ws, err = websocket.connect('ws://127.0.0.1:8080/ws') | ||
if not ws then | ||
print('failed to connect: ' .. err) | ||
return | ||
end | ||
|
||
local bytes, err = ws:send_text('Hello') | ||
if not bytes then | ||
print('failed to send frame: ', err) | ||
return | ||
end | ||
|
||
local data, typ, err = ws:recv_frame() | ||
if not data then | ||
print('failed to receive the frame: ', err) | ||
return | ||
end | ||
|
||
print('received: ', data, ' (', typ, '): ', err) | ||
|
||
local bytes, err = ws:send_close(1000, 'bye') | ||
if not bytes then | ||
print('failed to send frame: ', err) | ||
return | ||
end |
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters