diff --git a/README.md b/README.md index 1c40985..0cd806a 100644 --- a/README.md +++ b/README.md @@ -1,34 +1,37 @@ -websockets -========== +# websockets -Introduction ------------- +![Hackage Version](https://img.shields.io/hackage/v/websockets) +![GitHub Workflow Status (with event)](https://img.shields.io/github/actions/workflow/status/jaspervdj/websockets/ci.yml) -Provides a sensible, clean and simple way to write WebSocket-capable servers in -Haskell. +Provides a sensible, clean and simple way to write WebSocket +server and client in Haskell. -The following program echoes messages back after appending `meow`: +## Features -```haskell -{-# LANGUAGE OverloadedStrings #-} -import Control.Monad (forever) -import qualified Data.Text as T -import qualified Network.WebSockets as WS +- Provides Server/Client implementations of the websocket protocol +- Ping/Pong building blocks for stale connection checking +- TLS support via [wuss](https://hackage.haskell.org/package/wuss) package -meow :: WS.Connection -> IO () -meow conn = forever $ do - msg <- WS.receiveData conn - WS.sendTextData conn $ msg `T.append` ", meow" -``` +## Caveats + +- [Doesn't implement client ping/pong](https://github.com/jaspervdj/websockets/issues/159) +- [Send doesn't support streaming](https://github.com/jaspervdj/websockets/issues/119) +- [Requires careful handling of exceptions](https://github.com/jaspervdj/websockets/issues/48) +- [DeflateCompression isn't thread-safe](https://github.com/jaspervdj/websockets/issues/208) + +## Introduction + +See [server](./example/server.lhs) and [client](./example/client.hs) implementations. + +## Installation -Installation is provided using cabal: +Using cabal: ``` $ cabal install websockets ``` -Authors -------- +## Authors An initial WebSockets library was written in 2010 by Siniša Biđin. In 2011, it was rewritten from scratch, and extended to its current state by Jasper Van der @@ -43,9 +46,9 @@ Contributors: - Nathan Howell - Steffen Schuldenzucker - Yi Huang +- Domen Kožar -Development ------------ +## Development Pull requests are always welcome! diff --git a/stack.yaml b/stack.yaml index 8708666..523d9bc 100644 --- a/stack.yaml +++ b/stack.yaml @@ -3,7 +3,6 @@ save-hackage-creds: false flags: websockets: example: true - website: true extra-deps: - 'hakyll-4.15.1.0' nix: diff --git a/web/.gitignore b/web/.gitignore deleted file mode 100644 index e640867..0000000 --- a/web/.gitignore +++ /dev/null @@ -1,7 +0,0 @@ -_cache -_site - -README.markdown -example.lhs -reference -site diff --git a/web/css/default.css b/web/css/default.css deleted file mode 100644 index ef371a9..0000000 --- a/web/css/default.css +++ /dev/null @@ -1,83 +0,0 @@ -html { - color: #000; - font-family: monospace; - font-size: 14px; - text-align: left; - background-color: #eee; -} - -body { - padding: 0px; - margin: 0px 0px 20px 0px; -} - -div#navigation { - background-color: #002b36; - padding: 20px 5px 5px 25px; - margin: 0px; -} - -div#navigation a { - color: #fff; - font-size: 16px; - margin-right: 10px; -} - -div#content { - padding: 25px; - width: 700px; -} - -div#content-wide { - margin: 0px; - padding: 0px; - background-color: #fff; -} - -div#footer { - font-size: 11px; - padding: 10px 10px 10px 25px; -} - -h1 { - font-size: 24px; - font-weight: bold; - margin-top: 15px; - padding: 0px; -} - -h2 { - font-size: 18px; - font-weight: normal; - margin-top: 25px; - padding: 0px; -} - -a { - color: #002b36; - font-weight: bold; - text-decoration: none; -} - -pre code { - background-color: #eee; - border: 1px solid #888; - display: block; - margin: 10px; - padding: 5px; -} - -table { - border-collapse: collapse; - border: 1px solid black; - margin-left: 10px; -} - -table th { - border-bottom: 1px solid black; - padding: 2px 8px 2px 8px; -} - -table td { - padding: 2px 8px 2px 8px; -} diff --git a/web/css/syntax.css b/web/css/syntax.css deleted file mode 100644 index 1aed859..0000000 --- a/web/css/syntax.css +++ /dev/null @@ -1,18 +0,0 @@ -/* Generated by pandoc. */ -table.sourceCode, tr.sourceCode, td.lineNumbers, td.sourceCode, table.sourceCode pre - { margin: 0; padding: 0; border: 0; vertical-align: baseline; border: none; } -td.lineNumbers { border-right: 1px solid #AAAAAA; text-align: right; color: #AAAAAA; padding-right: 5px; padding-left: 5px; } -td.sourceCode { padding-left: 5px; } -pre.sourceCode span.kw { color: #007020; font-weight: bold; } -pre.sourceCode span.dt { color: #902000; } -pre.sourceCode span.dv { color: #40a070; } -pre.sourceCode span.bn { color: #40a070; } -pre.sourceCode span.fl { color: #40a070; } -pre.sourceCode span.ch { color: #4070a0; } -pre.sourceCode span.st { color: #4070a0; } -pre.sourceCode span.co { color: #60a0b0; font-style: italic; } -pre.sourceCode span.ot { color: #007020; } -pre.sourceCode span.al { color: red; font-weight: bold; } -pre.sourceCode span.fu { color: #06287e; } -pre.sourceCode span.re { } -pre.sourceCode span.er { color: red; font-weight: bold; } diff --git a/web/site.hs b/web/site.hs deleted file mode 100644 index 92d89cc..0000000 --- a/web/site.hs +++ /dev/null @@ -1,59 +0,0 @@ --------------------------------------------------------------------------------- -{-# LANGUAGE Arrows #-} -{-# LANGUAGE OverloadedStrings #-} -{-# LANGUAGE ScopedTypeVariables #-} -{-# OPTIONS_GHC -fno-warn-unused-do-bind #-} -module Main where - - --------------------------------------------------------------------------------- -import Hakyll -import System.FilePath (joinPath, splitFileName, splitPath, (>)) - - --------------------------------------------------------------------------------- -pageCompiler :: Compiler (Item String) -pageCompiler = - pandocCompiler >>= - loadAndApplyTemplate "web/templates/default.html" defaultContext >>= - relativizeUrls - - --------------------------------------------------------------------------------- -main :: IO () -main = hakyllWith config $ do - match "README.md" $ do - route $ constRoute "index.html" - compile $ pageCompiler >>= relativizeUrls - - match "example/server.lhs" $ do - route $ setExtension ".html" - compile $ pageCompiler >>= relativizeUrls - - match (fromList - [ "example/client.html" - , "example/client.js" - , "example/screen.css" - ]) $ do - route $ idRoute - compile copyFileCompiler - - match "web/css/*" $ do - route dropWebRoute - compile compressCssCompiler - - match "web/templates/*" $ - compile templateCompiler - where - config = defaultConfiguration - { deployCommand = "rsync --checksum -ave 'ssh -p 2222' _site/* \ - \jaspervdj@jaspervdj.be:jaspervdj.be/websockets" - } - --- | Drop the `web/` part from a route. -dropWebRoute :: Routes -dropWebRoute = customRoute $ \ident -> - let path0 = toFilePath ident in - case splitPath path0 of - "web/" : path1 -> joinPath path1 - _ -> path0 diff --git a/web/templates/default.html b/web/templates/default.html deleted file mode 100644 index 4d63222..0000000 --- a/web/templates/default.html +++ /dev/null @@ -1,33 +0,0 @@ - - - -
- -