https://github.com/regadas/dispatch-pusher
Scala dispatch publishing library for Pusher
https://github.com/regadas/dispatch-pusher
Last synced: 7 months ago
JSON representation
Scala dispatch publishing library for Pusher
- Host: GitHub
- URL: https://github.com/regadas/dispatch-pusher
- Owner: regadas
- Created: 2011-12-15T15:10:49.000Z (over 14 years ago)
- Default Branch: master
- Last Pushed: 2012-01-15T12:30:06.000Z (over 14 years ago)
- Last Synced: 2025-01-29T08:24:09.925Z (over 1 year ago)
- Language: Scala
- Homepage:
- Size: 93.8 KB
- Stars: 3
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
dispatch-pusher
===============
Scala [dispatch](https://github.com/dispatch/dispatch) publishing library for [Pusher](http://pusher.com)
## Usage
* using [SBT](https://github.com/harrah/xsbt) on `build.scala` put the following:
```
resolvers ++= Seq("regadas repo" at "https://github.com/regadas/repo/raw/master")
libraryDependencies += "com.regadas" %% "dispatch-pusher" % "0.1"
```
* depends on [dispatch](https://github.com/dispatch/dispatch).
```
libraryDependencies += "net.databinder" %% "dispatch-http" % "0.8.6"
```
* finally ... test example ...
```scala
val vars = List("PUSHER_KEY", "PUSHER_SECRET", "PUSHER_APIID")
val (key :: secret :: apiId :: Nil) = vars.map { v => Option(System.getenv(v)) }
key aka "PUSHER_KEY env variable" must beSome
secret aka "PUSHER_SECRET env variable" must beSome
apiId aka "PUSHER_APIID env variable" must beSome
//setting pusher credentials
val pusher = PusherRequest(key.get, secret.get)_
//specify
val channel = pusher(apiId.get, "test_channel")
//specify the event to trigger and the data to be sent ... socket id is optional
val pushToMyEvent: Request = channel("my_event", "hello world", Some("1"))
val pushToYourEvent: Request = channel("your_event", "hello world again", None)
val http = new Http
val requests = List(pushToMyEvent, pushToYourEvent)
requests.map { req =>
val status :Int = http(( req >:> identity) {
case (status, _, _, _) => status
})
status must_==202
}
```