https://github.com/soylent-grin/scala-stomp-websocket-client
https://github.com/soylent-grin/scala-stomp-websocket-client
client scala stomp websocket
Last synced: 5 months ago
JSON representation
- Host: GitHub
- URL: https://github.com/soylent-grin/scala-stomp-websocket-client
- Owner: soylent-grin
- Created: 2018-05-21T13:37:41.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-06-14T20:34:27.000Z (about 8 years ago)
- Last Synced: 2023-08-10T10:22:28.177Z (almost 3 years ago)
- Topics: client, scala, stomp, websocket
- Language: Scala
- Size: 7.81 KB
- Stars: 0
- Watchers: 2
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Scala STOMP WebSocket Client
Prerequisites
-------------
* Scala 2.11.x
### Installation
Add the following line to your sbt dependencies:
```scala
"com.github.vooolll" %% "scala-stomp-websocket-client" % "0.1.2"
```
Note: make sure that you have in your `build.sbt`
```scala
resolvers += Resolver.sonatypeRepo("releases")
```
## Done and ready to use
* STOMP 1.1 without heartbeat
* `CONNECT`, `SUBSCRIBE`, `UNSUBSCRIBE`, `DISCONNECT`, `ERROR` frame handling
* Custom WS endpoint and HTTP headers
* Integration with Play! Framework (no Netty-dependency issues because of standalone WS transport)
## Not ready to use
* `RECEIPT` frame and `receipe-id` header
* `ACK`, `NACK`, `BEGIN`, `COMMIT`, `ABORT` frames
* Custom heartbeat
### Example
```scala
object Main extends App {
val client = new MessageBrokerClient(
"ws://example.com/msgbroker/",
"login",
"passcode",
Map(
"My-Header" -> "123"
)
)
client.onConnect(_ => {
print("connected!")
client.subscribe("/topic/one/*", (msg) => {
println(s"received message! $msg")
client.unsubscribe("/topic/one/*")
client.disconnect()
})
}).onFailure({
case t: Throwable =>
println(s"failure! ${t.getMessage}")
case _ =>
// do nothing
}).onDisconnect(_ => {
println("disconnected!")
}).connect()
}
```