# \[ANN\] Websocket - High level API for Server and Client with documentation

**URL:** <https://discourse.julialang.org/t/ann-websocket-high-level-api-for-server-and-client-with-documentation/47957>\
**Category:** Package Announcements\
**Tags:** package, networking, http\
**Created:** [October 7, 2020, 10:05pm UTC](https://discourse.julialang.org/t/ann-websocket-high-level-api-for-server-and-client-with-documentation/47957 "2020-10-07T22:05:48Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![citkane](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/citkane/32/17595_2.png) [@citkane](https://discourse.julialang.org/u/citkane)\
**Post date:** [October 7, 2020, 10:05pm UTC](https://discourse.julialang.org/t/ann-websocket-high-level-api-for-server-and-client-with-documentation/47957/1 "2020-10-07T22:05:48Z")

</div>

# Websocket.jl

[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://citkane.github.io/Websocket.jl/stable) [![](https://img.shields.io/badge/docs-dev-blue.svg)](https://citkane.github.io/Websocket.jl/dev)

[Github Code](https://github.com/citkane/Websocket.jl)

### Why another Websocket package?

The existing Julia websocket solutions are in various states of development and lack comprehensive high level API’s comparable to offerings in other languages such as JS and Python.

For this reason I have ported the architecture of the popular Node.js [websocket](https://www.npmjs.com/package/websocket) package into Julia.

## Basic usage server:

```julia
using Websocket

server = WebsocketServer()
ended = Condition() 

listen(server, :client) do client
    listen(client, :message) do message
        @info "Got a message" client = client.id message = message
        send(client, "Echo back at you: $message")
    end
end
listen(server, :connectError) do err
    logWSerror(err)
    notify(ended, err.msg, error = true)
end
listen(server, :closed) do details
    @warn "Server has closed" details...
    notify(ended)
end

@async serve(server; verbose = true)
wait(ended)

```

## Basic usage client:

```julia
using Websocket

client = WebsocketClient()
ended = Condition()

listen(client, :connect) do ws
    listen(ws, :message) do message
        @info message
    end
    listen(ws, :close) do reason
        @warn "Websocket connection closed" reason...
        notify(ended)
    end
    for count = 1:10
        send(ws, "hello $count")
        sleep(1)
    end
    close(ws)
end
listen(client, :connectError) do err
    logWSerror(err)
    notify(ended, err.msg, error = true)
end

@async open(client, "ws://localhost:8080")
wait(ended)

```

---

<div class="post-metadata">

**Author:** ![mthelm85](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mthelm85/32/224164_2.png) [@mthelm85](https://discourse.julialang.org/u/mthelm85)\
**Post date:** [October 7, 2020, 10:39pm UTC](https://discourse.julialang.org/t/ann-websocket-high-level-api-for-server-and-client-with-documentation/47957/2 "2020-10-07T22:39:28Z")

</div>

Nice! I’m super excited to take this for a spin!!

---

<div class="post-metadata">

**Author:** ![citkane](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/citkane/32/17595_2.png) [@citkane](https://discourse.julialang.org/u/citkane)\
**Post date:** [October 8, 2020, 11:13am UTC](https://discourse.julialang.org/t/ann-websocket-high-level-api-for-server-and-client-with-documentation/47957/3 "2020-10-08T11:13:39Z")

</div>

I just added:  
[![](https://img.shields.io/badge/docs-stable-blue.svg)](https://citkane.github.io/Websocket.jl/stable) [![](https://img.shields.io/badge/docs-dev-blue.svg)](https://citkane.github.io/Websocket.jl/dev)  
as v0.0.3 which builds documentation as a Github Page.

This documentation has `source` links @ bottom right of code snippets, whereas the Juliahub documentation build appears to omit the link.

---

<div class="post-metadata">

**Author:** ![citkane](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/citkane/32/17595_2.png) [@citkane](https://discourse.julialang.org/u/citkane)\
**Post date:** [October 9, 2020, 2:45pm UTC](https://discourse.julialang.org/t/ann-websocket-high-level-api-for-server-and-client-with-documentation/47957/4 "2020-10-09T14:45:38Z")

</div>

I have been asked nicely by a human at JuliaRegistry to rename this package because of potential confusion with the existing `WebSockets` package.

This package is now called [SimpleWebsockets](https://github.com/citkane/SimpleWebsockets.jl) and should appear on the registry shortly.

[Websocket](https://juliahub.com/ui/Packages/Websocket/OSqTk) will be deprecated shortly in favor of SimpleWebsockets. (once I have figured out how to do that!)

---

<div class="post-metadata">

**Author:** ![citkane](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/citkane/32/17595_2.png) [@citkane](https://discourse.julialang.org/u/citkane)\
**Post date:** [October 9, 2020, 2:56pm UTC](https://discourse.julialang.org/t/ann-websocket-high-level-api-for-server-and-client-with-documentation/47957/5 "2020-10-09T14:56:54Z")

</div>

@avik  
Could you help with deprecating the old package please.  
I am looking at [this post](https://discourse.julialang.org/t/how-do-i-deprecate-a-package/14129/2) , but am a bit confused.

Setting the upper bound: I assume this is in Project.toml [compat] - could you give an example of the value

> just send a PR to metadata to add the upper bound to _all_ released versions of the package.

Any idea how to do that?

Or is there a formal way to do the whole deprecation procedure?
