Skip to content

stejin/DandelionWebSockets.jl

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

DandelionWebSockets

DandelionWebSockets is a client side WebSocket package.

Usage

Create a subtype of WebSocketHandler, with callbacks for WebSocket events. Create a WSClient and connect to a WebSocket server.

type MyHandler <: WebSocketHandler
    client::WSClient
end

# These are called when you get a text or binary frame, respectively.
on_text(handler::MyHandler, text::UTF8String) = ...
on_binary(handler::MyHandler, data::Vector{UInt8}) = ...

# These are called when the state of the WebSocket changes.
state_connecting(handler::MyHandler) = ...
state_open(handler::MyHandler)       = ...
state_closing(handler::MyHandler)    = ...
state_closed(handler::MyHandler)     = ...

The following functions are available on WSClient, to send frames to the server.

send_text(c::WSClient, s::UTF8String)
send_binary(c::WSClient, data::Vector{UInt8})

# Close the WebSocket.
stop(c::WSClient)

To connect to a WebSocket server, call wsconnect(client::WSClient, uri::URI, handler::WebSocketHandler).

Needs work

  • Implement regular pings, to ensure the connection is up.
  • Wait for Requests.jl next release. This package needs a HTTP Upgrade feature of Requests.jl, which is only present in master, not in the release 0.3.7.
  • Ability to send multi-frame messages.

License

DandelionWebSockets is licensed under the MIT license.

About

A Julia package for client side WebSockets.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Julia 100.0%