diff --git a/pom.xml b/pom.xml index e11e6110c53748e3f15eeee1eeec2e8ae224913a..8f43474ad93041f02daa629c04e8299e41144502 100644 --- a/pom.xml +++ b/pom.xml @@ -96,6 +96,17 @@ <artifactId>slf4j-api</artifactId> </dependency> + <dependency> + <groupId>org.webjars</groupId> + <artifactId>webjars-locator</artifactId> + <version>[0.30,)</version> + </dependency> + <dependency> + <groupId>org.webjars</groupId> + <artifactId>atmosphere-javascript</artifactId> + <version>2.3.2</version> + </dependency> + <dependency> <groupId>org.springframework</groupId> <artifactId>spring-websocket</artifactId> diff --git a/src/main/java/cern/c2mon/client/atmosphere/TagUpdateMessage.java b/src/main/java/cern/c2mon/client/atmosphere/TagUpdateMessage.java index 814166ff76bd4d21f28941df93d4a0df5cfd74f2..d3ee8640ca4f06fe4a30ef0f75b03bfc83108827 100644 --- a/src/main/java/cern/c2mon/client/atmosphere/TagUpdateMessage.java +++ b/src/main/java/cern/c2mon/client/atmosphere/TagUpdateMessage.java @@ -25,7 +25,7 @@ public class TagUpdateMessage implements SimplifiedTag { public TagUpdateMessage(Tag tag){ this.setId(tag.getId()) .setName(tag.getName()) - .setValue(tag.getValue().toString()) + .setValue(tag.getValue()!=null?tag.getValue().toString():"") .setControlTag(tag.isControlTag()) .setAliveTag(tag.isAliveTag()) .setTimestamp(tag.getTimestamp().getTime()) diff --git a/src/main/resources/static/index.html b/src/main/resources/static/index.html index a6175b5140e2df54683abac656611f0b109d1902..64c2165bdb0a68641d11d91fa221980ff8482869 100644 --- a/src/main/resources/static/index.html +++ b/src/main/resources/static/index.html @@ -1,5 +1,8 @@ <html> -<head><title>C2MON Atmosphere Publisher</title></head> +<head> +<title>C2MON Atmosphere Publisher</title> + +</head> <body> <h1>Hello world !</h1> </body> diff --git a/src/main/resources/static/test/index.html b/src/main/resources/static/test/index.html new file mode 100644 index 0000000000000000000000000000000000000000..e172f243e38f60bb5c6f58156e2e325ed8a1e6ff --- /dev/null +++ b/src/main/resources/static/test/index.html @@ -0,0 +1,39 @@ +<html> +<head> +<title>C2MON Atmosphere Publisher Sanity Testing Page</title> +<script src="../webjars/atmosphere-javascript/atmosphere.js"></script> +</head> +<body> +<h1>Test</h1> +<script> + var socket = atmosphere; + var request = new atmosphere.AtmosphereRequest(); + request.url = "../broadcast"; + request.contentType = "application/json"; + request.transport = 'websocket'; + request.fallbackTransport = 'long-polling'; + request.onOpen = function(response){ + console.log('Atmosphere connected using ' + response.transport); + subSocket.push(JSON.stringify({add:["dip://dip/acc/LHC/RunControl/Page1"]})); + }; + request.onMessage = function (response) { + console.log('Atmosphere received : '+response.responseBody); + try { + var json = JSON.parse(response.responseBody); + console.log('JSON message : ',json); + } catch (e) { + console.log('Error: ', response.responseBody); + return; + } + + }; + + request.onError = function(response) { + console.log('Atmosphere error :', response.responseBody); + }; + + var subSocket = socket.subscribe(request); + +</script> +</body> +</html> \ No newline at end of file