ScalaWebSocket provides Scala vocabulary for async-http-client's WebSocket support.
Currently compiled against Scala 2.10.0
Current version is 0.1.1
ScalaWebSocket lives in Sonatype's repositories and releases are synced to Maven Central. To use snapshot versions, simply add Sonatype snapshot repository to resolvers.
resolvers += "Sonatype snapshots" at "http://oss.sonatype.org/content/repositories/snapshots/"
libraryDependncies += "eu.piotrbuda" %% "scalawebsocket" % "0.1.1"
<dependency>
<groupId>eu.piotrbuda</groupId>
<artifactId>scalawebsocket_2.10</artifactId>
<version>0.1.1</version>
</dependency>
WebSocket().open("ws://echo.websocket.org/").sendText("text").close().shutdown()
WebSocket().open("ws://echo.websocket.org/").onTextMessage(msg => doSomethingWithMessage(msg))
To be able to remove a handler from WebSocket, it has to be a named handler.
val handler = {
msg: String => doSomethingWithMessage(msg)
}
WebSocket.open(url).onTextMessage(handler).sendText("text").removeOnTextMessage(handler)
Credit has to go to @jfarcand as I used testing part of his WCS project project.
Copyright 2013 Piotr Buda
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.