https://github.com/softprops/tubesocks
A comfortable and fashionable way to have bi-directional conversations with modern web servers.
https://github.com/softprops/tubesocks
Last synced: 11 months ago
JSON representation
A comfortable and fashionable way to have bi-directional conversations with modern web servers.
- Host: GitHub
- URL: https://github.com/softprops/tubesocks
- Owner: softprops
- License: mit
- Created: 2012-06-21T03:19:16.000Z (almost 14 years ago)
- Default Branch: master
- Last Pushed: 2016-11-03T03:21:19.000Z (over 9 years ago)
- Last Synced: 2025-07-19T05:55:31.147Z (11 months ago)
- Language: Scala
- Size: 27.3 KB
- Stars: 14
- Watchers: 5
- Forks: 2
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- awesome-scala - Tubesocks ★ 12 ⧗ 174 - Library supporting bi-directional communication with websocket servers. (HTTP)
README
# tubesocks
[](https://travis-ci.org/softprops/tubesocks)
A comfortable _and_ fashionable way to have bi-directional conversations with modern web servers.
Tubesocks is a snug little interface that wraps [async http client][ahc] which supports an emerging standard protocol for pushing
messages to clients and responding over an open connection.
Here is an `echo` client.
```scala
import tubesocks._
Sock.uri("ws://host") {
case Message(m, s) => s.send(m)
}
```
## install
### sbt
By hand (cut & paste)
```scala
libraryDependencies += "me.lessis" %% "tubesocks" % "0.1.0"
```
The [civilized way](https://github.com/softprops/ls#readme)
ls-install tubesocks
## usage
```scala
import tubesocks._
Sock.uri("ws://host.com") {
case Open(s) => s.send("I'm here")
case Message(t, s) => println("server says %s" format t)
case Close(s) => println("we're done")
}
```
Do you prefer configuring your own transmission?
```scala
import tubesocks._
Sock.configure({ b =>
b.setWebSocketIdleTimeoutInMs(2 * 60 * 1000)
})(new URI("ws://host.com")) {
case Message(t, s) => s.send("thanks for the message")
}
```
Doug Tangren (softprops) 2012-2013
[ahc]: https://github.com/sonatype/async-http-client