All Projects → weavejester → Haslett

weavejester / Haslett

A lightweight WebSocket library for ClojureScript

Programming Languages

clojure
4091 projects
clojurescript
191 projects

Projects that are alternatives of or similar to Haslett

Aiowebsocket
Async WebSocket Client. Advantage: Flexible Lighter and Faster
Stars: ✭ 263 (+78.91%)
Mutual labels:  async, websocket
Laravel S
LaravelS is an out-of-the-box adapter between Swoole and Laravel/Lumen.
Stars: ✭ 3,479 (+2266.67%)
Mutual labels:  async, websocket
Rsocket Kotlin
RSocket Kotlin multi-platform implementation
Stars: ✭ 256 (+74.15%)
Mutual labels:  async, websocket
Async Tungstenite
Async binding for Tungstenite, the Lightweight stream-based WebSocket implementation
Stars: ✭ 207 (+40.82%)
Mutual labels:  async, websocket
Netcoreserver
Ultra fast and low latency asynchronous socket server & client C# .NET Core library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution
Stars: ✭ 799 (+443.54%)
Mutual labels:  async, websocket
Swoole Src
🚀 Coroutine-based concurrency library for PHP
Stars: ✭ 17,175 (+11583.67%)
Mutual labels:  async, websocket
Microwebsrv2
The last Micro Web Server for IoTs (MicroPython) or large servers (CPython), that supports WebSockets, routes, template engine and with really optimized architecture (mem allocations, async I/Os). Ready for ESP32, STM32 on Pyboard, Pycom's chipsets (WiPy, LoPy, ...). Robust, efficient and documented!
Stars: ✭ 295 (+100.68%)
Mutual labels:  async, websocket
Channelstream
Channelstream is a websocket communication server for web applications
Stars: ✭ 52 (-64.63%)
Mutual labels:  async, websocket
Ratchet
Asynchronous WebSocket server
Stars: ✭ 5,596 (+3706.8%)
Mutual labels:  async, websocket
Cppserver
Ultra fast and low latency asynchronous socket server & client C++ library with support TCP, SSL, UDP, HTTP, HTTPS, WebSocket protocols and 10K connections problem solution
Stars: ✭ 528 (+259.18%)
Mutual labels:  async, websocket
Ws Promise Client
PROJECT MOVED: https://github.com/kdex/ws-promise
Stars: ✭ 6 (-95.92%)
Mutual labels:  async, websocket
Ws Machine
WS-Machine is a websocket finite state machine for client websocket connections (Go)
Stars: ✭ 110 (-25.17%)
Mutual labels:  async, websocket
Functional Promises
Write code like a story w/ a powerful Fluent (function chaining) API
Stars: ✭ 141 (-4.08%)
Mutual labels:  async
Require Vuejs
RequireJS plugin to async and dynamic load and parse .vue components
Stars: ✭ 143 (-2.72%)
Mutual labels:  async
Mobc
A generic connection pool for Rust with async/await support
Stars: ✭ 141 (-4.08%)
Mutual labels:  async
Ember Phoenix
Phoenix Framework integration and tooling for Ember.js apps
Stars: ✭ 140 (-4.76%)
Mutual labels:  websocket
Xactor
Xactor is a rust actors framework based on async-std
Stars: ✭ 146 (-0.68%)
Mutual labels:  async
Unityfx.async
Asynchronous operations (promises) for Unity3d.
Stars: ✭ 143 (-2.72%)
Mutual labels:  async
Workerman Todpole
HTML5+WebSocket+PHP(Workerman) , rumpetroll server writen using php
Stars: ✭ 1,751 (+1091.16%)
Mutual labels:  websocket
Websocketdemo
在Spring Boot中使用WebSocket,示例包括简单模式、STOMP模式消息、处理对方不在线情况、分布式WebSocket等。
Stars: ✭ 140 (-4.76%)
Mutual labels:  websocket

Haslett

Build Status

A lightweight WebSocket library for ClojureScript that uses core.async.

Installation

Add the following dependency to your project.clj file:

[haslett "0.1.6"]

Usage

Haslett provides a simple and idiomatic interface to using WebSockets:

(ns example.core
  (:require-macros [cljs.core.async.macros :refer [go]])
  (:require [cljs.core.async :as a :refer [<! >!]]
            [haslett.client :as ws]
            [haslett.format :as fmt]))

(go (let [stream (<! (ws/connect "ws://echo.websocket.org"))]
      (>! (:sink stream) "Hello World")
      (js/console.log (<! (:source stream)))
      (ws/close stream)))

The connect function returns a promise channel that produces a map with four keys: :socket, :close-status, :source and :sink.

  • :socket contains the JavaScript WebSocket object, in case you need to access it directly.

  • :close-status contains a promise channel that a status map is delivered to when the socket is closed. The status map will provide a :code and :reason keys that will explain why the socket was closed.

  • :source is a core.async channel to read from.

  • :sink is a core.async channel to write to.

By default, Haslett sends raw strings, but we can change that by supplying a formatter. Haslett includes formatters for JSON, edn and Transit:

(go (let [stream (<! (ws/connect "ws://echo.websocket.org" {:format fmt/transit}))]
      (>! (:sink stream) {:foo [1 2 3]})
      (js/console.log (pr-str (<! (:source stream))))
      (ws/close stream)))

You can customize the behaviour further by supplying your own channels for the source and sink. This allows you to tune the channel buffer, and add tranducers:

(ws/connect "ws://echo.websocket.org"
            {:source (a/chan 10)
             :sink   (a/chan 10)})

When the WebSocket is closed, the :sink and :source channels are also closed. In addition, a final status map will be delivered to a promise channel held in the :close-status key on the stream.

License

Copyright © 2019 James Reeves

Distributed under the Eclipse Public License either version 1.0 or (at your option) any later version.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].