-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
modified: README.md Replace client example new:examples/client_repl_input.jl Same as README.md modified: examples/minimal_server.jl More prints, as in README modified: examples/minimal_server_HTTP.jl More prints modified: src/HTTP.jl Stricter wsuri checks modified: test/client_test.jl Check errors bad wsuri
- Loading branch information
Showing
6 changed files
with
114 additions
and
50 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
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,33 @@ | ||
using HTTP | ||
using WebSockets | ||
function client_one_message(ws) | ||
print_with_color(:green, STDOUT, "\nws|client input > ") | ||
msg = readline(STDIN) | ||
if writeguarded(ws, msg) | ||
msg, stillopen = readguarded(ws) | ||
println("Received:", String(msg)) | ||
if stillopen | ||
println("The connection is active, but we leave. WebSockets.jl will close properly.") | ||
else | ||
println("Disconnect during reading.") | ||
end | ||
else | ||
println("Disconnect during writing.") | ||
end | ||
end | ||
function main() | ||
while true | ||
println("\nWebSocket client side. WebSocket URI format:") | ||
println("ws:// host [ \":\" port ] path [ \"?\" query ]") | ||
println("Example:\nws://127.0.0.1:8080") | ||
println("Where do you want to connect? Empty line to exit") | ||
print_with_color(:green, STDOUT, "\nclient_repl_input > ") | ||
wsuri = readline(STDIN) | ||
wsuri == "" && break | ||
res = WebSockets.open(client_one_message, wsuri) | ||
!isa(res, HTTP.Response) && println(res) | ||
end | ||
println("Have a nice day") | ||
end | ||
|
||
main() |
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
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