=doc update stream-io doc page to the latest API

* style changes remove double border from inline code blocks
This commit is contained in:
Martynas Mickevičius 2015-08-28 09:35:23 +03:00
parent 3ba3de55b6
commit ccfbc390b9
5 changed files with 22 additions and 14 deletions

View file

@ -47,7 +47,10 @@ class StreamTcpDocSpec extends AkkaSpec {
println(s"New connection from: ${connection.remoteAddress}")
val echo = Flow[ByteString]
.via(Framing.delimiter(ByteString("\n"), maximumFrameLength = 256, allowTruncation = true))
.via(Framing.delimiter(
ByteString("\n"),
maximumFrameLength = 256,
allowTruncation = true))
.map(_.utf8String)
.map(_ + "!!!\n")
.map(ByteString(_))
@ -86,7 +89,10 @@ class StreamTcpDocSpec extends AkkaSpec {
val welcome = Source.single(ByteString(welcomeMsg))
val echo = b.add(Flow[ByteString]
.via(Framing.delimiter(ByteString("\n"), maximumFrameLength = 256, allowTruncation = true))
.via(Framing.delimiter(
ByteString("\n"),
maximumFrameLength = 256,
allowTruncation = true))
.map(_.utf8String)
//#welcome-banner-chat-server
.map { command serverProbe.ref ! command; command }
@ -106,9 +112,9 @@ class StreamTcpDocSpec extends AkkaSpec {
connection.handleWith(serverLogic)
}
//#welcome-banner-chat-server
import akka.stream.io.Framing
//#welcome-banner-chat-server
val input = new AtomicReference("Hello world" :: "What a lovely day" :: Nil)
def readLine(prompt: String): String = {
@ -138,7 +144,10 @@ class StreamTcpDocSpec extends AkkaSpec {
}
val repl = Flow[ByteString]
.via(Framing.delimiter(ByteString("\n"), maximumFrameLength = 256, allowTruncation = true))
.via(Framing.delimiter(
ByteString("\n"),
maximumFrameLength = 256,
allowTruncation = true))
.map(_.utf8String)
.map(text => println("Server: " + text))
.map(_ => readLine("> "))

View file

@ -16,7 +16,7 @@ Streaming TCP
Accepting connections: Echo Server
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
In order to implement a simple EchoServer we ``bind`` to a given address, which returns a ``Source[IncomingConnection]``,
In order to implement a simple EchoServer we ``bind`` to a given address, which returns a ``Source[IncomingConnection, Future[ServerBinding]]``,
which will emit an :class:`IncomingConnection` element for each new connection that the Server should handle:
.. includecode:: code/docs/stream/io/StreamTcpDocSpec.scala#echo-server-simple-bind
@ -35,8 +35,8 @@ incoming connection Flow, since it directly corresponds to an existing, already
only ever be materialized *once*.
Closing connections is possible by cancelling the *incoming connection* :class:`Flow` from your server logic (e.g. by
connecting its downstream to an :class:`CancelledSink` and its upstream to a *completed* :class:`Source`).
It is also possible to shut down the servers socket by cancelling the ``connections:Source[IncomingConnection]``.
connecting its downstream to a :class:`Sink.cancelled` and its upstream to a :class:`Source.empty`).
It is also possible to shut down the server's socket by cancelling the :class:`IncomingConnection` source ``connections``.
We can then test the TCP server by sending data to the TCP Socket using ``netcat``: