Package

io.backchat

hookup

Permalink

package hookup

The package object for the library. This contains some implicit conversions to smooth the api over and allow for a single import at the top of a file to get the api working.

Linear Supertypes
AnyRef, Any
Ordering
  1. Alphabetic
  2. By inheritance
Inherited
  1. hookup
  2. AnyRef
  3. Any
  1. Hide All
  2. Show all
Visibility
  1. Public
  2. All

Type Members

  1. case class AckFailed(message: OutboundMessage) extends InboundMessage with Product with Serializable

    Permalink

    A callback event signaling failure of an ack request.

    A callback event signaling failure of an ack request. This is not handled automatically and you have to decide what you want to do with the message, you could send it again, send it somewhere else, drop it ...

    message

    An io.backchat.hookup.OutboundMessage outbound message

  2. trait Ackable extends AnyRef

    Permalink

    Adds acking support to a message This can only be included in a websocket out message

  3. trait BackupBuffer extends Closeable

    Permalink

    Interface trait to which fallback mechanisms must adhere to It implements java.io.Closeable so you can use it as a resource

  4. case class BinaryMessage(content: Array[Byte]) extends ProtocolMessage[Array[Byte]] with Product with Serializable

    Permalink

    A message representing an array of bytes sent to/received from a remote party.

    A message representing an array of bytes sent to/received from a remote party.

    content

    An Array of Bytes representing the content of the message

  5. trait BroadcastChannel extends BroadcastChannelLike

    Permalink

    A broadcast channel represents a connection

  6. trait BroadcastChannelLike extends AnyRef

    Permalink

    Broadcast channel like is either a connection or a proxy for a connection.

    Broadcast channel like is either a connection or a proxy for a connection. It contains the methods for sending and disconnecting from a socket

  7. trait Connectable extends AnyRef

    Permalink

    A trait describing a client that can connect to something

  8. case class ContentCompression(level: Int = 6) extends ServerCapability with Product with Serializable

    Permalink

    Configuration for content compression

    Configuration for content compression

    level

    the compression level

  9. abstract class DefaultHookupClient extends HookupClient

    Permalink

    Usage of the simple websocket client:

    Usage of the simple websocket client:

      new DefaultHookupClient(HookupClientConfig(new URI("ws://localhost:8080/thesocket"))) {
    
        def receive = {
          case Disconnected(_) ⇒ println("The websocket to " + uri.toASCIIString + " disconnected.")
          case TextMessage(message) ⇒ {
            println("RECV: " + message)
            send("ECHO: " + message)
          }
        }
    
        connect() onSuccess {
          case Success ⇒
            println("The websocket is connected.")
          case _ ⇒
        }
      }
    

  10. case class Disconnected(cause: Option[Throwable]) extends InboundMessage with Product with Serializable

    Permalink

    A callback event signaling that the connection has ended, if the cause was an exception thrown then the cause object will be filled in.

    A callback event signaling that the connection has ended, if the cause was an exception thrown then the cause object will be filled in.

    cause

    A scala.Option of java.lang.Throwable

  11. case class Error(cause: Option[Throwable]) extends InboundMessage with Product with Serializable

    Permalink

    A callback event signaling that an error has occurred.

    A callback event signaling that an error has occurred. if the error was an exception thrown then the cause object will be filled in.

    cause

    A scala.Option of java.lang.Throwable

  12. case class Favico(path: File) extends ServerCapability with Product with Serializable

    Permalink

    The file to use as favico.ico response.

    The file to use as favico.ico response. If you use the public directory capabillity you can also place a file in the public directory named favico.{ico,png,gif} and the static file server will serve the request.

    path

    The java.io.File to use as base path

  13. class FileBuffer extends BackupBuffer

    Permalink

    The default file buffer.

    The default file buffer. This is a file buffer that also has a memory buffer to which it writes when the file stream is being read out or if a write to the file failed.

    This class has no maximum size or any limits attached to it yet. So it is possible for this class to exhaust the memory and/or disk space of the machine using this buffer.

  14. case class FlashPolicy(domain: String, ports: Seq[Int]) extends ServerCapability with Product with Serializable

    Permalink

    The configuration for the flash policy xml

    The configuration for the flash policy xml

    domain

    the domain to accept connections for

    ports

    the ports to accept connections on

  15. trait HookupClient extends HookupClientLike with Connectable with Reconnectable with Closeable

    Permalink

    The Hookup client provides a client for the hookup server, it doesn't lock you in to using a specific message format.

    The Hookup client provides a client for the hookup server, it doesn't lock you in to using a specific message format. The default implementation uses websockets to communicate with the server. You can opt-in or opt-out of every feature in the hookup client through configuration.

    Usage of the simple hookup client:

      new HookupClient {
        val uri = new URI("ws://localhost:8080/thesocket")
    
        def receive = {
          case Disconnected(_) ⇒ println("The websocket to " + uri.toASCIIString + " disconnected.")
          case TextMessage(message) ⇒ {
            println("RECV: " + message)
            send("ECHO: " + message)
          }
        }
    
        connect() onSuccess {
          case Success ⇒
            println("The websocket to " + uri.toASCIIString + "is connected.")
          case _ ⇒
        }
      }
    

    See also

    io.backchat.hookup.HookupClientConfig

  16. case class HookupClientConfig(uri: URI, version: WebSocketVersion = WebSocketVersion.V13, initialHeaders: Map[String, String] = Map.empty, protocols: Seq[WireFormat] = DefaultProtocols, defaultProtocol: WireFormat = ..., pinging: Timeout = Timeout(60 seconds), buffer: Option[BackupBuffer] = None, throttle: Throttle = NoThrottle, executionContext: ExecutionContext = HookupClient.executionContext) extends Product with Serializable

    Permalink

    The configuration of a websocket client.

    The configuration of a websocket client.

    uri

    The java.net.URI to connect to.

    version

    The version of the websocket handshake to use, defaults to the most recent version.

    initialHeaders

    The headers to send along with the handshake request.

    protocols

    The protocols this websocket client can understand

    defaultProtocol

    the default protocol this client should use

    pinging

    The timeout for pinging.

    buffer

    The buffer to use when the connection to the server is lost.

    throttle

    The throttle to use as reconnection schedule.

    executionContext

    The execution context for futures.

  17. trait HookupClientLike extends BroadcastChannelLike

    Permalink

    A trait describing an entity that can handle inbound messages

  18. class HookupServer extends Server

    Permalink

    Netty based HookupServer requires netty 3.4.x or later

    Netty based HookupServer requires netty 3.4.x or later

    Usage:

    val server = HookupServer(ServerInfo("MyWebSocketServer")) {
      new HookupServerClient {
        protected val receive = {
          case Connected ⇒ println("got a client connection")
          case TextMessage(text) ⇒ send(TextMessage("ECHO: " + text))
          case Disconnected(_) ⇒ println("client disconnected")
        }
      }
    }
    server.start
    // time passes......
    server.stop
  19. type HookupServerClient = hookup.HookupServer.HookupServerClient

    Permalink

    Type forwarder for a websocket server client

  20. sealed trait InboundMessage extends AnyRef

    Permalink

    A marker trait for inbound messages

  21. case class IndefiniteThrottle(delay: Duration, maxWait: Duration) extends Throttle with Product with Serializable

    Permalink

    Represents a back off strategy that will retry forever when the maximum wait has been reached From then on it will continue to use the max wait as delay.

    Represents a back off strategy that will retry forever when the maximum wait has been reached From then on it will continue to use the max wait as delay.

    delay

    An scala.concurrent.duration.Duration indicating how long to wait for the next operation can occur

    maxWait

    An scala.concurrent.duration.Duration indicating the maximum value a delay can have

  22. trait JavaHelpers extends WebSocketListener

    Permalink

    A mixin for a io.backchat.hookup.HookupClient with helper methods for the java api.

    A mixin for a io.backchat.hookup.HookupClient with helper methods for the java api. When mixed into a websocket it is a full implementation that notifies the registered io.backchat.hookup.WebSocketListener instances when events occur.

  23. class JavaHookupClient extends DefaultHookupClient with JavaHelpers

    Permalink

    A java friendly websocket

  24. case class JsonMessage(content: JValue) extends ProtocolMessage[JValue] with Product with Serializable

    Permalink

    A message representing a json object sent to/received from a remote party.

    A message representing a json object sent to/received from a remote party.

    content

    A org.json4s.JValue object

  25. class JsonProtocolWireFormat extends WireFormat

    Permalink

    A protocol that supports all the features of the websocket server.

    A protocol that supports all the features of the websocket server. This wireformat knows about acking and the related protocol messages. it uses a json object to transfer meaning everything has a property name.

  26. case class MaxFrameSize(size: Long = Long.MaxValue) extends ServerCapability with Product with Serializable

    Permalink

    The maximum frame size for a websocket connection

  27. case class MaxTimesThrottle(delay: Duration, maxWait: Duration, maxTimes: Int = 1) extends Throttle with Product with Serializable

    Permalink

    Represents a back off strategy that will retry for maxTimes when the maximum wait has been reached When it can't connect within the maxTimes a maxValue can occur it will return a io.backchat.hookup.NoThrottle strategy

    Represents a back off strategy that will retry for maxTimes when the maximum wait has been reached When it can't connect within the maxTimes a maxValue can occur it will return a io.backchat.hookup.NoThrottle strategy

    delay

    An scala.concurrent.duration.Duration indicating how long to wait for the next operation can occur

    maxWait

    An scala.concurrent.duration.Duration indicating the maximum value a delay can have

    maxTimes

    A scala.Int representing the maximum amount of time a maxWait can be repeated

  28. class MemoryBuffer extends BackupBuffer

    Permalink
  29. sealed trait OperationResult extends AnyRef

    Permalink

    The interface to represent a result from an operation These results can indicate Success, Cancellation or a sequence of operation results

  30. sealed trait OutboundMessage extends AnyRef

    Permalink

    A marker trait for outbound messages

  31. case class Ping(timeout: Timeout) extends ServerCapability with Product with Serializable

    Permalink

    The configuration for sending pings to a client.

    The configuration for sending pings to a client. (Some websocket clients don't support ping frames)

    timeout

    the timeout for a connection to be idle before sending a ping.

  32. trait ProtocolMessage[T] extends InboundMessage with OutboundMessage with Ackable

    Permalink

    A base trait for creating messages of different content types

    A base trait for creating messages of different content types

    T

    The type of content this protocol message represents

  33. case class PublicDirectory(path: File) extends ServerCapability with Product with Serializable

    Permalink

    The directory to use as a base directory for serving static files.

    The directory to use as a base directory for serving static files.

    path

    The java.io.File to use as base path

  34. trait Reconnectable extends AnyRef

    Permalink

    A trait describing a client that can reconnect to a server.

  35. case class ResultList(results: List[OperationResult]) extends OperationResult with Product with Serializable

    Permalink

    A list of operation results, contains some aggregate helper methods in addition to a populated list of children

    A list of operation results, contains some aggregate helper methods in addition to a populated list of children

    results

    a scala.List of io.backchat.hookup.OperationResult objects

  36. class ScalaUpstreamHandler extends AnyRef

    Permalink
  37. trait Server extends AnyRef

    Permalink

    A trait to wrap a server in so it can be used by components that depend on a most basic interfae.

  38. trait ServerCapability extends AnyRef

    Permalink

    A marker trait to indicate something is a a configuration for the server.

  39. case class ServerInfo(name: String = ServerInfo.DefaultServerName, version: String = BuildInfo.version, listenOn: String = "0.0.0.0", port: Int = 8765, defaultProtocol: String = DefaultProtocol, capabilities: Seq[ServerCapability] = Seq.empty, executionContext: ExecutionContext = HookupClient.executionContext) extends Product with Serializable

    Permalink

    Main configuration object for a server

    Main configuration object for a server

    name

    The name of this server, defaults to BackchatWebSocketServer

    version

    The version of the server

    listenOn

    Which address the server should listen on

    port

    The port the server should listen on

    defaultProtocol

    The default protocol for this server to use when no subprotocols have been specified

    capabilities

    A sequence of io.backchat.hookup.ServerCapability configurations for this server

  40. class SimpleJsonWireFormat extends WireFormat

    Permalink

    A protocol format that is just plain and simple json.

    A protocol format that is just plain and simple json. This protocol doesn't support acking. It looks at the first character in the message and if it thinks it's JSON it will try to parse it as JSON otherwise it creates a text message

  41. case class SslSupport(keystorePath: String = sys.props("keystore.file.path"), keystorePassword: String = sys.props("keystore.file.password"), algorithm: String = ...) extends ServerCapability with Product with Serializable

    Permalink

    Configuration for adding ssl support to the server

    Configuration for adding ssl support to the server

    keystorePath

    path to the keystore, by default it looks for the system property keystore.file.path

    keystorePassword

    path to the keystore, by default it looks for the system property keystore.file.path

    algorithm

    path to the keystore, by default it looks for the system property keystore.file.path

  42. case class SubProtocols(protocol: WireFormat, protocols: WireFormat*) extends ServerCapability with Product with Serializable

    Permalink

    The subprotocols this server can respond to.

    The subprotocols this server can respond to.

    protocol

    A supported protocol name

    protocols

    remaining supported protocols

  43. case class TextMessage(content: String) extends ProtocolMessage[String] with Product with Serializable

    Permalink

    A message representing a text object sent to/received from a remote party.

    A message representing a text object sent to/received from a remote party.

    content

    A scala.Predef.String representing the content of the message

  44. trait Throttle extends AnyRef

    Permalink

    The interface for an immutable backoff schedule

  45. trait WebSocketListener extends AnyRef

    Permalink

    A base class for the java api to listen for websocket events.

  46. trait WireFormat extends AnyRef

    Permalink

    The interface trait for a wire format.

    The interface trait for a wire format. Creating a new wire format means implementing these 3 methods.

Value Members

  1. object BuildInfo extends Product with Serializable

    Permalink

    This object was generated by sbt-buildinfo.

  2. object Cancelled extends OperationResult with Product with Serializable

    Permalink

    An object indicating a failure result

  3. object Connected extends InboundMessage with Product with Serializable

    Permalink

    A callback event signaling that the connection has been fully established.

    A callback event signaling that the connection has been fully established. This means that any handshakes have been completed successfully too.

    When you receive this callback message you can be sure there is someone on the other end.

  4. var DefaultProtocol: String

    Permalink

    The default protocol for the hookup server to use.

    The default protocol for the hookup server to use. By default this a simple json protocol that doesn't support any advanced features but just sends json messages back and forth

  5. val DefaultProtocols: Seq[WireFormat]

    Permalink

    The default protocols hookup understands

  6. object FileBuffer

    Permalink

    Companion object for the io.backchat.hookup.FileBuffer

  7. object HookupClient

    Permalink

  8. object HookupServer

    Permalink

  9. val HttpCacheSeconds: Int

    Permalink
  10. val HttpDateFormat: DateTimeFormatter

    Permalink
  11. val HttpDateGMT: String

    Permalink
  12. val HttpDateTimeZone: DateTimeZone

    Permalink
  13. val JsonProtocol: JsonProtocolWireFormat

    Permalink
  14. object JsonProtocolWireFormat

    Permalink

  15. object NoThrottle extends Throttle with Product with Serializable

    Permalink

    A Null object representing no backing off at all

  16. object Reconnecting extends InboundMessage with Product with Serializable

    Permalink

    A callback event signaling that the connection to the server has been broken and the client is trying to reconnect.

    A callback event signaling that the connection to the server has been broken and the client is trying to reconnect. Every reconnect attempt fires this message.

    Typically you don't need to do anything when this happens, if you use a backoff like io.backchat.hookup.IndefiniteThrottle then the client does the reconnection bit automatically, it's only then that you can expect these events.

  17. object ServerInfo extends Serializable

    Permalink

  18. val SimpleJson: SimpleJsonWireFormat

    Permalink
  19. object Success extends OperationResult with Product with Serializable

    Permalink

    An object indicating a success result

  20. implicit def channelFutureToAkkaFuture(fut: ChannelFuture): AnyRef { def toAkkaFuture(implicit context: scala.concurrent.ExecutionContext): scala.concurrent.Promise[io.backchat.hookup.OperationResult] }

    Permalink

    An implicit conversion from a org.jboss.netty.channel.ChannelFuture to an scala.concurrent.Future

    An implicit conversion from a org.jboss.netty.channel.ChannelFuture to an scala.concurrent.Future

    fut

    The org.jboss.netty.channel.ChannelFuture

    returns

    A scala.concurrent.Future

  21. package examples

    Permalink
  22. implicit def fn2BroadcastFilter(fn: (BroadcastChannel) ⇒ Boolean): BroadcastFilter

    Permalink

    An implicit conversion from a predicate function that takes a io.backchat.hookup.BroadcastChannel to a io.backchat.hookup.HookupServer.BroadcastFilter

    An implicit conversion from a predicate function that takes a io.backchat.hookup.BroadcastChannel to a io.backchat.hookup.HookupServer.BroadcastFilter

    fn

    The predicate function to convert to a filter

    returns

    A io.backchat.hookup.HookupServer.BroadcastFilter

  23. def getDefaultProtocol(): String

    Permalink
  24. def getDefaultProtocols(): Seq[WireFormat]

    Permalink
  25. package http

    Permalink
  26. implicit def jvalue2JsonMessage(content: JValue): OutboundMessage with Ackable

    Permalink

    Implicit conversion from a json4s jvalue to a io.backchat.hookup.JsonMessage

    Implicit conversion from a json4s jvalue to a io.backchat.hookup.JsonMessage

    content

    The string content of the message

    returns

    A io.backchat.hookup.JsonMessage

  27. package server

    Permalink
  28. def setDefaultProtocol(arg0: String): Unit

    Permalink

    The default protocol for the hookup server to use.

    The default protocol for the hookup server to use. By default this a simple json protocol that doesn't support any advanced features but just sends json messages back and forth

Inherited from AnyRef

Inherited from Any

Ungrouped