From d998f4f8ca3b8c64190cee68d0297576edb77af1 Mon Sep 17 00:00:00 2001 From: "R. Tyler Croy" Date: Mon, 24 Nov 2014 22:52:48 -0800 Subject: [PATCH] Allow the for grepping message bodies from the web frontend Fixes #6 Fixes #8 --- src/ratpack/handlebars/topic-watch.html.hbs | 24 +++++++++++++++++---- src/ratpack/ratpack.groovy | 12 +++++------ 2 files changed, 26 insertions(+), 10 deletions(-) diff --git a/src/ratpack/handlebars/topic-watch.html.hbs b/src/ratpack/handlebars/topic-watch.html.hbs index cc13939..998715e 100644 --- a/src/ratpack/handlebars/topic-watch.html.hbs +++ b/src/ratpack/handlebars/topic-watch.html.hbs @@ -1,10 +1,18 @@ {{> header}}
-
-
- Loading.. -
+
+
+
+ Loading.. +
+
+ +
+
+ +
+
@@ -15,5 +23,13 @@ {{> footer}} diff --git a/src/ratpack/ratpack.groovy b/src/ratpack/ratpack.groovy index a90877b..52cb489 100644 --- a/src/ratpack/ratpack.groovy +++ b/src/ratpack/ratpack.groovy @@ -44,16 +44,16 @@ ratpack { } get('topics/:name/websocket') { ctx -> - println "creating thingies" def client = new OfftopicClient(Configuration.instance) - println "client: ${client}" + def grepper = null websocket(ctx) { ws -> println "Connected ${ws}" client.onMessageCallback = { m -> - println "called back with ${m}" - ws.send(groovy.json.JsonOutput.toJson(m)) - println "sent message" + println "called back with ${m} (grep: ${grepper})" + if ((grepper == null) || (m.raw =~ grepper)) { + ws.send(groovy.json.JsonOutput.toJson(m)) + } } client.createSubscribersFor(pathTokens.name) print "subscribers created for ${pathTokens.name}" @@ -63,7 +63,7 @@ ratpack { client.shutdown() } sock.onMessage { msg -> - println "client sent ${msg}" + grepper = msg.text } } }