aboutsummaryrefslogtreecommitdiff
path: root/docs/streaming-custom-receivers.md
diff options
context:
space:
mode:
Diffstat (limited to 'docs/streaming-custom-receivers.md')
-rw-r--r--docs/streaming-custom-receivers.md48
1 files changed, 24 insertions, 24 deletions
diff --git a/docs/streaming-custom-receivers.md b/docs/streaming-custom-receivers.md
index 479140f519..fae5901e8d 100644
--- a/docs/streaming-custom-receivers.md
+++ b/docs/streaming-custom-receivers.md
@@ -59,8 +59,8 @@ class CustomReceiver(host: String, port: Int)
}
def onStop() {
- // There is nothing much to do as the thread calling receive()
- // is designed to stop by itself if isStopped() returns false
+ // There is nothing much to do as the thread calling receive()
+ // is designed to stop by itself if isStopped() returns false
}
/** Create a socket connection and receive data until receiver is stopped */
@@ -68,29 +68,29 @@ class CustomReceiver(host: String, port: Int)
var socket: Socket = null
var userInput: String = null
try {
- // Connect to host:port
- socket = new Socket(host, port)
-
- // Until stopped or connection broken continue reading
- val reader = new BufferedReader(
- new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8))
- userInput = reader.readLine()
- while(!isStopped && userInput != null) {
- store(userInput)
- userInput = reader.readLine()
- }
- reader.close()
- socket.close()
-
- // Restart in an attempt to connect again when server is active again
- restart("Trying to connect again")
+ // Connect to host:port
+ socket = new Socket(host, port)
+
+ // Until stopped or connection broken continue reading
+ val reader = new BufferedReader(
+ new InputStreamReader(socket.getInputStream(), StandardCharsets.UTF_8))
+ userInput = reader.readLine()
+ while(!isStopped && userInput != null) {
+ store(userInput)
+ userInput = reader.readLine()
+ }
+ reader.close()
+ socket.close()
+
+ // Restart in an attempt to connect again when server is active again
+ restart("Trying to connect again")
} catch {
- case e: java.net.ConnectException =>
- // restart if could not connect to server
- restart("Error connecting to " + host + ":" + port, e)
- case t: Throwable =>
- // restart if there is any other error
- restart("Error receiving data", t)
+ case e: java.net.ConnectException =>
+ // restart if could not connect to server
+ restart("Error connecting to " + host + ":" + port, e)
+ case t: Throwable =>
+ // restart if there is any other error
+ restart("Error receiving data", t)
}
}
}