Skip to content

Commit

Permalink
update docs.
Browse files Browse the repository at this point in the history
  • Loading branch information
Robey Pointer committed Dec 26, 2008
1 parent e13c23a commit 82cdde2
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 19 deletions.
10 changes: 5 additions & 5 deletions src/main/scala/net/lag/naggati/IoHandlerActorAdapter.scala
Expand Up @@ -8,7 +8,7 @@ import net.lag.logging.Logger

/**
* All messages sent to an actor in reference to a Mina <code>IoSession</code>
* will be a subclass of <code>MinaMessage</code>.
* will be a subclass of `MinaMessage`.
*/
abstract sealed class MinaMessage
object MinaMessage {
Expand All @@ -22,7 +22,7 @@ object MinaMessage {


/**
* Converts Mina <code>IoSession</code> events into messages to be sent to
* Converts Mina `IoSession` events into messages to be sent to
* an actor.
*/
class IoHandlerActorAdapter(val actorFactory: (IoSession) => Actor) extends IoHandler {
Expand Down Expand Up @@ -82,8 +82,8 @@ object IoHandlerActorAdapter {
/**
* Return the actor associated with a Mina session, if any.
* An actor is created for each new Mina session automatically by the
* factory passed to an <code>IoHandlerActorAdapter</code>, or can be
* set manually by <code>setActorFor</code>.
* factory passed to an `IoHandlerActorAdapter`, or can be
* set manually by `setActorFor`.
*/
def actorFor(session: IoSession): Option[Actor] = {
val actor = session.getAttribute(ACTOR_KEY).asInstanceOf[Actor]
Expand All @@ -92,7 +92,7 @@ object IoHandlerActorAdapter {

/**
* Manually set the actor that should receive I/O event messages for a
* given Mina <code>IoSession</code>.
* given Mina `IoSession`.
*/
def setActorFor(session: IoSession, actor: Actor) = session.setAttribute(ACTOR_KEY, actor)
}
14 changes: 7 additions & 7 deletions src/main/scala/net/lag/naggati/State.scala
Expand Up @@ -7,15 +7,15 @@ import org.apache.mina.filter.codec.ProtocolDecoderOutput


/**
* Container for state associated with a Mina <code>IoSession</code>,
* Container for state associated with a Mina `IoSession`,
* including the current incoming data buffer and arbitrary key/value data
* used by the decoding logic. A state object is associated with a session
* when the session is first created, and stays attached as long as the
* session is alive.
*/
class State protected[naggati](firstStep: Step, val session: IoSession, val out: ProtocolDecoderOutput) {
/**
* Current buffer being processed.
* Current (mina) buffer being processed.
*/
var buffer: IoBuffer = IoBuffer.EMPTY_BUFFER

Expand All @@ -38,11 +38,11 @@ class State protected[naggati](firstStep: Step, val session: IoSession, val out:

/**
* Add an IoBuffer from mina into our current state. If our current
* buffer is empty, we optimistically just store the buffer from mina,
* buffer is empty, we optimistically store the buffer from mina,
* in the hopes that it can be completely processed inline. If we have
* leftovers, though, we build our own cumulative buffer.
*
* After this method returns, 'buffer' is in flipped mode and contains
* After this method returns, `buffer` is in flipped mode and contains
* any previous data plus the new data.
*/
private[naggati] def addBuffer(in: IoBuffer) = {
Expand All @@ -69,12 +69,12 @@ class State protected[naggati](firstStep: Step, val session: IoSession, val out:
}

/**
* Retrieve a named value from the state map in <code>data</code>.
* Retrieve a named value from the state map in `data`.
*/
def apply(key: String) = data(key)

/**
* Set a named value in the state map in <code>data</code>.
* Set a named value in the state map in `data`.
*/
def update(key: String, value: Any) = data(key) = value

Expand Down Expand Up @@ -106,7 +106,7 @@ class State protected[naggati](firstStep: Step, val session: IoSession, val out:
}

/**
* Return a view of the key/value data store (in <code>data</code>) where
* Return a view of the key/value data store (in `data`) where
* the values are all ints that default to 0 if not present yet.
*/
def asInt = intMapping
Expand Down
11 changes: 5 additions & 6 deletions src/main/scala/net/lag/naggati/Step.scala
Expand Up @@ -8,14 +8,13 @@ case object COMPLETE extends StepResult("complete")

/**
* Abstract base class for a "step" in a state machine. Steps are executed
* when called (via <code>apply</code>) and return either
* <code>NEED_DATA</code> if more data must be buffered before the step can
* complete, or <code>COMPLETE</code> if the step has processed the data
* when called (via `apply`) and return either
* `NEED_DATA` if more data must be buffered before the step can
* complete, or `COMPLETE` if the step has processed the data
* buffered so far and processing should move on to the next step.
*
* <p>
* Steps can be put into an implicit order via the <code>::</code> operator,
* but many of the built-in steps (in the <code>Steps</code> object) take
* Steps can be put into an implicit order via the `::` operator,
* but many of the built-in steps (in the `Steps` object) take
* a code block as a parameter, with the code block providing the next Step
* to execute.
*/
Expand Down
2 changes: 1 addition & 1 deletion src/test/scala/net/lag/naggati/asn1/TagSpec.scala
Expand Up @@ -12,7 +12,6 @@ object TagSpec extends Specification {
private var fakeSession: IoSession = null
private var fakeDecoderOutput: ProtocolDecoderOutput = null

// FIXME push this down into configgy
def unhexlify(s: String): Array[Byte] = {
val buffer = new Array[Byte](s.length / 2)
for (val i <- 0.until(s.length, 2)) {
Expand All @@ -21,6 +20,7 @@ object TagSpec extends Specification {
buffer
}


private class TagDecoder extends Decoder(Tag.reader("out")) {
val fakeSession = new DummySession
val fakeDecoderOutput = new ProtocolDecoderOutput {
Expand Down

0 comments on commit 82cdde2

Please sign in to comment.