Skip to content

Commit

Permalink
WebSocket Example, See JuliaLang/MbedTLS.jl#186 (comment)
Browse files Browse the repository at this point in the history
  • Loading branch information
samoconnor committed Nov 8, 2018
1 parent df13276 commit f3437c7
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,26 @@ HTTP.serve() do request::HTTP.Request
end
```

## WebSocket Examples

```julia
julia> @async HTTP.WebSockets.listen("127.0.0.1", UInt16(8081)) do ws
while !eof(ws)
data = readavailable(ws)
write(ws, data)
end
end

julia> HTTP.WebSockets.open("ws://127.0.0.1:8081") do ws
write(ws, "Hello")
x = readavailable(ws)
@show x
println(String(x))
end;
x = UInt8[0x48, 0x65, 0x6c, 0x6c, 0x6f]
Hello
```

[docs-latest-img]: https://img.shields.io/badge/docs-latest-blue.svg
[docs-latest-url]: https://JuliaWeb.github.io/HTTP.jl/latest

Expand Down

0 comments on commit f3437c7

Please sign in to comment.