scala-stomp-websocket-client

Scala STOMP web socket client

License

License

Categories

Categories

Scala Languages CLI User Interface
GroupId

GroupId

com.github.vooolll
ArtifactId

ArtifactId

scala-stomp-websocket-client_2.11
Last Version

Last Version

0.1.2
Release Date

Release Date

Type

Type

jar
Description

Description

scala-stomp-websocket-client
Scala STOMP web socket client
Project URL

Project URL

https://github.com/soylent-grin/scala-stomp-websocket-client
Project Organization

Project Organization

com.github.vooolll
Source Code Management

Source Code Management

https://github.com/soylent-grin/scala-stomp-websocket-client

Download scala-stomp-websocket-client_2.11

How to add to project

<!-- https://jarcasting.com/artifacts/com.github.vooolll/scala-stomp-websocket-client_2.11/ -->
<dependency>
    <groupId>com.github.vooolll</groupId>
    <artifactId>scala-stomp-websocket-client_2.11</artifactId>
    <version>0.1.2</version>
</dependency>
// https://jarcasting.com/artifacts/com.github.vooolll/scala-stomp-websocket-client_2.11/
implementation 'com.github.vooolll:scala-stomp-websocket-client_2.11:0.1.2'
// https://jarcasting.com/artifacts/com.github.vooolll/scala-stomp-websocket-client_2.11/
implementation ("com.github.vooolll:scala-stomp-websocket-client_2.11:0.1.2")
'com.github.vooolll:scala-stomp-websocket-client_2.11:jar:0.1.2'
<dependency org="com.github.vooolll" name="scala-stomp-websocket-client_2.11" rev="0.1.2">
  <artifact name="scala-stomp-websocket-client_2.11" type="jar" />
</dependency>
@Grapes(
@Grab(group='com.github.vooolll', module='scala-stomp-websocket-client_2.11', version='0.1.2')
)
libraryDependencies += "com.github.vooolll" % "scala-stomp-websocket-client_2.11" % "0.1.2"
[com.github.vooolll/scala-stomp-websocket-client_2.11 "0.1.2"]

Dependencies

compile (2)

Group / Artifact Type Version
org.scala-lang : scala-library jar 2.11.12
org.java-websocket : Java-WebSocket jar 1.3.8

Project Modules

There are no modules declared in this project.

Scala STOMP WebSocket Client

Prerequisites

  • Scala 2.11.x

Installation

Add the following line to your sbt dependencies:

"com.github.vooolll" %% "scala-stomp-websocket-client" % "0.1.2"

Note: make sure that you have in your build.sbt

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

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()
}

Versions

Version
0.1.2