Pārlūkot izejas kodu

Merge pull request #31 from bclozel/testing

Add integration test
Brian Clozel 9 gadi atpakaļ
vecāks
revīzija
388496a185

+ 18 - 13
README.adoc

@@ -4,15 +4,11 @@ projects: [spring-framework]
 ---
 :spring_version: current
 :spring_boot_version: 1.4.0.RELEASE
-:MappingJackson2MessageConverter: http://docs.spring.io/spring/docs/{spring_version}/javadoc-api/org/springframework/messaging/support/converter/MappingJackson2MessageConverter.html
 :jackson: http://wiki.fasterxml.com/JacksonHome
 :AtMessageMapping: http://docs.spring.io/spring/docs/{spring_version}/javadoc-api/org/springframework/messaging/handler/annotation/MessageMapping.html
 :AtController: http://docs.spring.io/spring/docs/{spring_version}/javadoc-api/org/springframework/stereotype/Controller.html
-:AtEnableWebSocket: http://docs.spring.io/spring/docs/{spring_version}/javadoc-api/org/springframework/web/socket/server/config/EnableWebSocket.html
 :AtEnableWebSocketMessageBroker: http://docs.spring.io/spring/docs/{spring_version}/javadoc-api/org/springframework/messaging/simp/config/EnableWebSocketMessageBroker.html
-:SpringApplication: http://docs.spring.io/spring-boot/docs/{spring_boot_version}/api/org/springframework/boot/SpringApplication.html
 :Stomp_JS: http://jmesnil.net/stomp-websocket/doc/
-:DispatcherServlet: http://docs.spring.io/spring/docs/{spring_version}/javadoc-api/org/springframework/web/servlet/DispatcherServlet.html
 :AtSendTo: http://docs.spring.io/spring/docs/{spring_version}/javadoc-api/org/springframework/messaging/handler/annotation/SendTo.html
 :toc:
 :icons: font
@@ -30,14 +26,11 @@ You'll build a server that will accept a message carrying a user's name. In resp
 
 == What you'll need
 
-:java_version: 1.8
 :java_version: 1.8
 include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/prereq_editor_jdk_buildtools.adoc[]
 
-
 include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/how_to_complete_this_guide.adoc[]
 
-
 include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/hide-show-gradle.adoc[]
 
 include::https://raw.githubusercontent.com/spring-guides/getting-started-macros/master/hide-show-maven.adoc[]
@@ -107,9 +100,9 @@ The {AtMessageMapping}[`@MessageMapping`] annotation ensures that if a message i
 
 The payload of the message is bound to a `HelloMessage` object which is passed into `greeting()`. 
 
-Internally, the implementation of the method simulates a processing delay by causing the thread to sleep for 3 seconds. This is to demonstrate that after the client sends a message, the server can take as long as it needs to process the message asynchronously.  The client may continue with whatever work it needs to do without waiting on the response.
+Internally, the implementation of the method simulates a processing delay by causing the thread to sleep for 1 second. This is to demonstrate that after the client sends a message, the server can take as long as it needs to process the message asynchronously.  The client may continue with whatever work it needs to do without waiting on the response.
 
-After the 3 second delay, the `greeting()` method creates a `Greeting` object and returns it. The return value is broadcast to all subscribers to "/topic/greetings" as specified in the {AtSendTo}[`@SendTo`] annotation.
+After the 1 second delay, the `greeting()` method creates a `Greeting` object and returns it. The return value is broadcast to all subscribers to "/topic/greetings" as specified in the {AtSendTo}[`@SendTo`] annotation.
 
 == Configure Spring for STOMP messaging
 
@@ -130,9 +123,10 @@ As its name suggests, `@EnableWebSocketMessageBroker` enables WebSocket message
 The `configureMessageBroker()` method overrides the default method in `WebSocketMessageBrokerConfigurer` to configure the message broker.
 It starts by calling `enableSimpleBroker()` to enable a simple memory-based message broker to carry the greeting messages back to the client on destinations prefixed with "/topic".
 It also designates the "/app" prefix for messages that are bound for `@MessageMapping`-annotated methods.
+This prefix will be used to define all the message mappings; for example, "/app/hello" is the endpoint that the `GreetingController.greeting()` method is mapped to handle.
+
+The `registerStompEndpoints()` method registers the "/gs-guide-websocket" endpoint, enabling SockJS fallback options so that alternate transports may be used if WebSocket is not available. The SockJS client will attempt to connect to "/gs-guide-websocket" and use the best transport available (websocket, xhr-streaming, xhr-polling, etc).
 
-The `registerStompEndpoints()` method registers the "/hello" endpoint, enabling SockJS fallback options so that alternative messaging options may be used if WebSocket is not available.
-This endpoint, when prefixed with "/app", is the endpoint that the `GreetingController.greeting()` method is mapped to handle.
 
 == Create a browser client
 
@@ -146,9 +140,20 @@ Create an index.html file that looks like this:
 include::complete/src/main/resources/static/index.html[]
 ----
 
-The main piece of this HTML file to pay attention to is the JavaScript code in the `connect()` and `sendName()` functions.
+This HTML file imports the `SockJS` and `STOMP` javascript libraries that will be used to communicate with our server
+using STOMP over websocket. We're also importing here an `app.js` which contains the logic of our client application.
+
+Let's create that file:
+
+`src/main/resources/static/app.js`
+[source,javascript]
+----
+include::complete/src/main/resources/static/app.js[]
+----
+
+The main piece of this JavaScript file to pay attention to is the `connect()` and `sendName()` functions.
 
-The `connect()` function uses https://github.com/sockjs[SockJS] and {Stomp_JS}[stomp.js] to open a connection to "/gs-messaging-stomp-websocket/hello", which is where `GreetingController` is waiting for connections. Upon a successful connection, it subscribes to the "/topic/greetings" destination, where the server will publish greeting messages. When a greeting is received on that destination, it will append a paragraph element to the DOM to display the greeting message.
+The `connect()` function uses https://github.com/sockjs[SockJS] and {Stomp_JS}[stomp.js] to open a connection to "/gs-guide-websocket", which is where our SockJS server is waiting for connections. Upon a successful connection, the client subscribes to the "/topic/greetings" destination, where the server will publish greeting messages. When a greeting is received on that destination, it will append a paragraph element to the DOM to display the greeting message.
 
 The `sendName()` function retrieves the name entered by the user and uses the STOMP client to send it to the "/app/hello" destination (where `GreetingController.greeting()` will receive it).
 

+ 8 - 4
complete/build.gradle

@@ -9,12 +9,11 @@ buildscript {
 
 apply plugin: 'java'
 apply plugin: 'eclipse'
-apply plugin: 'idea'
 apply plugin: 'spring-boot'
 
 jar {
     baseName = 'gs-messaging-stomp-websocket'
-    version =  '0.1.0'
+    version = '0.1.0'
 }
 sourceCompatibility = 1.8
 targetCompatibility = 1.8
@@ -25,7 +24,12 @@ repositories {
 
 dependencies {
     compile("org.springframework.boot:spring-boot-starter-websocket")
-    compile("org.springframework:spring-messaging")
-    testCompile("junit:junit")
+    compile("org.webjars:webjars-locator")
+    compile("org.webjars:sockjs-client:1.0.2")
+    compile("org.webjars:stomp-websocket:2.3.3")
+    compile("org.webjars:bootstrap:3.3.7")
+    compile("org.webjars:jquery:3.1.0")
+
+    testCompile("org.springframework.boot:spring-boot-starter-test")
 }
 

+ 30 - 3
complete/pom.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
     <groupId>org.springframework</groupId>
@@ -18,9 +18,36 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-websocket</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>org.webjars</groupId>
+            <artifactId>webjars-locator</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.webjars</groupId>
+            <artifactId>sockjs-client</artifactId>
+            <version>1.0.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.webjars</groupId>
+            <artifactId>stomp-websocket</artifactId>
+            <version>2.3.3</version>
+        </dependency>
         <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-messaging</artifactId>
+            <groupId>org.webjars</groupId>
+            <artifactId>bootstrap</artifactId>
+            <version>3.3.7</version>
+        </dependency>
+        <dependency>
+            <groupId>org.webjars</groupId>
+            <artifactId>jquery</artifactId>
+            <version>3.1.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
         </dependency>
     </dependencies>
 

+ 4 - 1
complete/src/main/java/hello/Greeting.java

@@ -1,9 +1,12 @@
 package hello;
 
 public class Greeting {
-    
+
     private String content;
 
+    public Greeting() {
+    }
+
     public Greeting(String content) {
         this.content = content;
     }

+ 1 - 1
complete/src/main/java/hello/GreetingController.java

@@ -11,7 +11,7 @@ public class GreetingController {
     @MessageMapping("/hello")
     @SendTo("/topic/greetings")
     public Greeting greeting(HelloMessage message) throws Exception {
-        Thread.sleep(3000); // simulated delay
+        Thread.sleep(1000); // simulated delay
         return new Greeting("Hello, " + message.getName() + "!");
     }
 

+ 11 - 1
complete/src/main/java/hello/HelloMessage.java

@@ -3,9 +3,19 @@ package hello;
 public class HelloMessage {
 
     private String name;
-    
+
+    public HelloMessage() {
+    }
+
+    public HelloMessage(String name) {
+        this.name = name;
+    }
+
     public String getName() {
         return name;
     }
 
+    public void setName(String name) {
+        this.name = name;
+    }
 }

+ 9 - 9
complete/src/main/java/hello/WebSocketConfig.java

@@ -10,15 +10,15 @@ import org.springframework.web.socket.config.annotation.StompEndpointRegistry;
 @EnableWebSocketMessageBroker
 public class WebSocketConfig extends AbstractWebSocketMessageBrokerConfigurer {
 
-	@Override
-	public void configureMessageBroker(MessageBrokerRegistry config) {
-		config.enableSimpleBroker("/topic");
-		config.setApplicationDestinationPrefixes("/app");
-	}
+    @Override
+    public void configureMessageBroker(MessageBrokerRegistry config) {
+        config.enableSimpleBroker("/topic");
+        config.setApplicationDestinationPrefixes("/app");
+    }
 
-	@Override
-	public void registerStompEndpoints(StompEndpointRegistry registry) {
-		registry.addEndpoint("/hello").withSockJS();
-	}
+    @Override
+    public void registerStompEndpoints(StompEndpointRegistry registry) {
+        registry.addEndpoint("/gs-guide-websocket").withSockJS();
+    }
 
 }

+ 51 - 0
complete/src/main/resources/static/app.js

@@ -0,0 +1,51 @@
+var stompClient = null;
+
+function setConnected(connected) {
+    $("#connect").prop("disabled", connected);
+    $("#disconnect").prop("disabled", !connected);
+    if (connected) {
+        $("#conversation").show();
+    }
+    else {
+        $("#conversation").hide();
+    }
+    $("#greetings").html("");
+}
+
+function connect() {
+    var socket = new SockJS('/gs-guide-websocket');
+    stompClient = Stomp.over(socket);
+    stompClient.connect({}, function (frame) {
+        setConnected(true);
+        console.log('Connected: ' + frame);
+        stompClient.subscribe('/topic/greetings', function (greeting) {
+            showGreeting(JSON.parse(greeting.body).content);
+        });
+    });
+}
+
+function disconnect() {
+    if (stompClient != null) {
+        stompClient.disconnect();
+    }
+    setConnected(false);
+    console.log("Disconnected");
+}
+
+function sendName() {
+    stompClient.send("/app/hello", {}, JSON.stringify({'name': $("#name").val()}));
+}
+
+function showGreeting(message) {
+    $("#greetings").append("<tr><td>" + message + "</td></tr>");
+}
+
+$(function () {
+    $("form").on('submit', function (e) {
+        e.preventDefault();
+    });
+    $( "#connect" ).click(function() { connect(); });
+    $( "#disconnect" ).click(function() { disconnect(); });
+    $( "#send" ).click(function() { sendName(); });
+});
+

+ 43 - 55
complete/src/main/resources/static/index.html

@@ -2,65 +2,53 @@
 <html>
 <head>
     <title>Hello WebSocket</title>
-    <script src="sockjs-0.3.4.js"></script>
-    <script src="stomp.js"></script>
-    <script type="text/javascript">
-        var stompClient = null;
-        
-        function setConnected(connected) {
-            document.getElementById('connect').disabled = connected;
-            document.getElementById('disconnect').disabled = !connected;
-            document.getElementById('conversationDiv').style.visibility = connected ? 'visible' : 'hidden';
-            document.getElementById('response').innerHTML = '';
-        }
-        
-        function connect() {
-            var socket = new SockJS('/hello');
-            stompClient = Stomp.over(socket);            
-            stompClient.connect({}, function(frame) {
-                setConnected(true);
-                console.log('Connected: ' + frame);
-                stompClient.subscribe('/topic/greetings', function(greeting){
-                    showGreeting(JSON.parse(greeting.body).content);
-                });
-            });
-        }
-        
-        function disconnect() {
-            if (stompClient != null) {
-                stompClient.disconnect();
-            }
-            setConnected(false);
-            console.log("Disconnected");
-        }
-        
-        function sendName() {
-            var name = document.getElementById('name').value;
-            stompClient.send("/app/hello", {}, JSON.stringify({ 'name': name }));
-        }
-        
-        function showGreeting(message) {
-            var response = document.getElementById('response');
-            var p = document.createElement('p');
-            p.style.wordWrap = 'break-word';
-            p.appendChild(document.createTextNode(message));
-            response.appendChild(p);
-        }
-    </script>
+    <link href="/webjars/bootstrap/css/bootstrap.min.css" rel="stylesheet">
+    <link href="/main.css" rel="stylesheet">
+    <script src="/webjars/jquery/jquery.min.js"></script>
+    <script src="/webjars/sockjs-client/sockjs.min.js"></script>
+    <script src="/webjars/stomp-websocket/stomp.min.js"></script>
+    <script src="/app.js"></script>
 </head>
-<body onload="disconnect()">
-<noscript><h2 style="color: #ff0000">Seems your browser doesn't support Javascript! Websocket relies on Javascript being enabled. Please enable
+<body>
+<noscript><h2 style="color: #ff0000">Seems your browser doesn't support Javascript! Websocket relies on Javascript being
+    enabled. Please enable
     Javascript and reload this page!</h2></noscript>
-<div>
-    <div>
-        <button id="connect" onclick="connect();">Connect</button>
-        <button id="disconnect" disabled="disabled" onclick="disconnect();">Disconnect</button>
+<div id="main-content" class="container">
+    <div class="row">
+        <div class="col-md-6">
+            <form class="form-inline">
+                <div class="form-group">
+                    <label for="connect">WebSocket connection:</label>
+                    <button id="connect" class="btn btn-default" type="submit">Connect</button>
+                    <button id="disconnect" class="btn btn-default" type="submit" disabled="disabled">Disconnect
+                    </button>
+                </div>
+            </form>
+        </div>
+        <div class="col-md-6">
+            <form class="form-inline">
+                <div class="form-group">
+                    <label for="name">What is your name?</label>
+                    <input type="text" id="name" class="form-control" placeholder="Your name here...">
+                </div>
+                <button id="send" class="btn btn-default" type="submit">Send</button>
+            </form>
+        </div>
     </div>
-    <div id="conversationDiv">
-        <label>What is your name?</label><input type="text" id="name" />
-        <button id="sendName" onclick="sendName();">Send</button>
-        <p id="response"></p>
+    <div class="row">
+        <div class="col-md-12">
+            <table id="conversation" class="table table-striped">
+                <thead>
+                <tr>
+                    <th>Greetings</th>
+                </tr>
+                </thead>
+                <tbody id="greetings">
+                </tbody>
+            </table>
+        </div>
     </div>
+    </form>
 </div>
 </body>
 </html>

+ 14 - 0
complete/src/main/resources/static/main.css

@@ -0,0 +1,14 @@
+body {
+    background-color: #f5f5f5;
+}
+
+#main-content {
+    max-width: 940px;
+    padding: 2em 3em;
+    margin: 0 auto 20px;
+    background-color: #fff;
+    border: 1px solid #e5e5e5;
+    -webkit-border-radius: 5px;
+    -moz-border-radius: 5px;
+    border-radius: 5px;
+}

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 24
complete/src/main/resources/static/sockjs-0.3.4.js


+ 0 - 475
complete/src/main/resources/static/stomp.js

@@ -1,475 +0,0 @@
-// Generated by CoffeeScript 1.7.1
-
-/*
-   Stomp Over WebSocket http://www.jmesnil.net/stomp-websocket/doc/ | Apache License V2.0
-
-   Copyright (C) 2010-2013 [Jeff Mesnil](http://jmesnil.net/)
-   Copyright (C) 2012 [FuseSource, Inc.](http://fusesource.com)
- */
-
-(function() {
-  var Byte, Client, Frame, Stomp,
-    __hasProp = {}.hasOwnProperty,
-    __slice = [].slice;
-
-  Byte = {
-    LF: '\x0A',
-    NULL: '\x00'
-  };
-
-  Frame = (function() {
-    var unmarshallSingle;
-
-    function Frame(command, headers, body) {
-      this.command = command;
-      this.headers = headers != null ? headers : {};
-      this.body = body != null ? body : '';
-    }
-
-    Frame.prototype.toString = function() {
-      var lines, name, value, _ref;
-      lines = [this.command];
-      _ref = this.headers;
-      for (name in _ref) {
-        if (!__hasProp.call(_ref, name)) continue;
-        value = _ref[name];
-        lines.push("" + name + ":" + value);
-      }
-      if (this.body) {
-        lines.push("content-length:" + (Frame.sizeOfUTF8(this.body)));
-      }
-      lines.push(Byte.LF + this.body);
-      return lines.join(Byte.LF);
-    };
-
-    Frame.sizeOfUTF8 = function(s) {
-      if (s) {
-        return encodeURI(s).split(/%..|./).length - 1;
-      } else {
-        return 0;
-      }
-    };
-
-    unmarshallSingle = function(data) {
-      var body, chr, command, divider, headerLines, headers, i, idx, len, line, start, trim, _i, _j, _len, _ref, _ref1;
-      divider = data.search(RegExp("" + Byte.LF + Byte.LF));
-      headerLines = data.substring(0, divider).split(Byte.LF);
-      command = headerLines.shift();
-      headers = {};
-      trim = function(str) {
-        return str.replace(/^\s+|\s+$/g, '');
-      };
-      _ref = headerLines.reverse();
-      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
-        line = _ref[_i];
-        idx = line.indexOf(':');
-        headers[trim(line.substring(0, idx))] = trim(line.substring(idx + 1));
-      }
-      body = '';
-      start = divider + 2;
-      if (headers['content-length']) {
-        len = parseInt(headers['content-length']);
-        body = ('' + data).substring(start, start + len);
-      } else {
-        chr = null;
-        for (i = _j = start, _ref1 = data.length; start <= _ref1 ? _j < _ref1 : _j > _ref1; i = start <= _ref1 ? ++_j : --_j) {
-          chr = data.charAt(i);
-          if (chr === Byte.NULL) {
-            break;
-          }
-          body += chr;
-        }
-      }
-      return new Frame(command, headers, body);
-    };
-
-    Frame.unmarshall = function(datas) {
-      var data;
-      return (function() {
-        var _i, _len, _ref, _results;
-        _ref = datas.split(RegExp("" + Byte.NULL + Byte.LF + "*"));
-        _results = [];
-        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
-          data = _ref[_i];
-          if ((data != null ? data.length : void 0) > 0) {
-            _results.push(unmarshallSingle(data));
-          }
-        }
-        return _results;
-      })();
-    };
-
-    Frame.marshall = function(command, headers, body) {
-      var frame;
-      frame = new Frame(command, headers, body);
-      return frame.toString() + Byte.NULL;
-    };
-
-    return Frame;
-
-  })();
-
-  Client = (function() {
-    var now;
-
-    function Client(ws) {
-      this.ws = ws;
-      this.ws.binaryType = "arraybuffer";
-      this.counter = 0;
-      this.connected = false;
-      this.heartbeat = {
-        outgoing: 10000,
-        incoming: 10000
-      };
-      this.maxWebSocketFrameSize = 16 * 1024;
-      this.subscriptions = {};
-    }
-
-    Client.prototype.debug = function(message) {
-      var _ref;
-      return typeof window !== "undefined" && window !== null ? (_ref = window.console) != null ? _ref.log(message) : void 0 : void 0;
-    };
-
-    now = function() {
-      return Date.now || new Date().valueOf;
-    };
-
-    Client.prototype._transmit = function(command, headers, body) {
-      var out;
-      out = Frame.marshall(command, headers, body);
-      if (typeof this.debug === "function") {
-        this.debug(">>> " + out);
-      }
-      while (true) {
-        if (out.length > this.maxWebSocketFrameSize) {
-          this.ws.send(out.substring(0, this.maxWebSocketFrameSize));
-          out = out.substring(this.maxWebSocketFrameSize);
-          if (typeof this.debug === "function") {
-            this.debug("remaining = " + out.length);
-          }
-        } else {
-          return this.ws.send(out);
-        }
-      }
-    };
-
-    Client.prototype._setupHeartbeat = function(headers) {
-      var serverIncoming, serverOutgoing, ttl, v, _ref, _ref1;
-      if ((_ref = headers.version) !== Stomp.VERSIONS.V1_1 && _ref !== Stomp.VERSIONS.V1_2) {
-        return;
-      }
-      _ref1 = (function() {
-        var _i, _len, _ref1, _results;
-        _ref1 = headers['heart-beat'].split(",");
-        _results = [];
-        for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
-          v = _ref1[_i];
-          _results.push(parseInt(v));
-        }
-        return _results;
-      })(), serverOutgoing = _ref1[0], serverIncoming = _ref1[1];
-      if (!(this.heartbeat.outgoing === 0 || serverIncoming === 0)) {
-        ttl = Math.max(this.heartbeat.outgoing, serverIncoming);
-        if (typeof this.debug === "function") {
-          this.debug("send PING every " + ttl + "ms");
-        }
-        this.pinger = Stomp.setInterval(ttl, (function(_this) {
-          return function() {
-            _this.ws.send(Byte.LF);
-            return typeof _this.debug === "function" ? _this.debug(">>> PING") : void 0;
-          };
-        })(this));
-      }
-      if (!(this.heartbeat.incoming === 0 || serverOutgoing === 0)) {
-        ttl = Math.max(this.heartbeat.incoming, serverOutgoing);
-        if (typeof this.debug === "function") {
-          this.debug("check PONG every " + ttl + "ms");
-        }
-        return this.ponger = Stomp.setInterval(ttl, (function(_this) {
-          return function() {
-            var delta;
-            delta = now() - _this.serverActivity;
-            if (delta > ttl * 2) {
-              if (typeof _this.debug === "function") {
-                _this.debug("did not receive server activity for the last " + delta + "ms");
-              }
-              return _this.ws.close();
-            }
-          };
-        })(this));
-      }
-    };
-
-    Client.prototype._parseConnect = function() {
-      var args, connectCallback, errorCallback, headers;
-      args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
-      headers = {};
-      switch (args.length) {
-        case 2:
-          headers = args[0], connectCallback = args[1];
-          break;
-        case 3:
-          if (args[1] instanceof Function) {
-            headers = args[0], connectCallback = args[1], errorCallback = args[2];
-          } else {
-            headers.login = args[0], headers.passcode = args[1], connectCallback = args[2];
-          }
-          break;
-        case 4:
-          headers.login = args[0], headers.passcode = args[1], connectCallback = args[2], errorCallback = args[3];
-          break;
-        default:
-          headers.login = args[0], headers.passcode = args[1], connectCallback = args[2], errorCallback = args[3], headers.host = args[4];
-      }
-      return [headers, connectCallback, errorCallback];
-    };
-
-    Client.prototype.connect = function() {
-      var args, errorCallback, headers, out;
-      args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
-      out = this._parseConnect.apply(this, args);
-      headers = out[0], this.connectCallback = out[1], errorCallback = out[2];
-      if (typeof this.debug === "function") {
-        this.debug("Opening Web Socket...");
-      }
-      this.ws.onmessage = (function(_this) {
-        return function(evt) {
-          var arr, c, client, data, frame, messageID, onreceive, subscription, _i, _len, _ref, _results;
-          data = typeof ArrayBuffer !== 'undefined' && evt.data instanceof ArrayBuffer ? (arr = new Uint8Array(evt.data), typeof _this.debug === "function" ? _this.debug("--- got data length: " + arr.length) : void 0, ((function() {
-            var _i, _len, _results;
-            _results = [];
-            for (_i = 0, _len = arr.length; _i < _len; _i++) {
-              c = arr[_i];
-              _results.push(String.fromCharCode(c));
-            }
-            return _results;
-          })()).join('')) : evt.data;
-          _this.serverActivity = now();
-          if (data === Byte.LF) {
-            if (typeof _this.debug === "function") {
-              _this.debug("<<< PONG");
-            }
-            return;
-          }
-          if (typeof _this.debug === "function") {
-            _this.debug("<<< " + data);
-          }
-          _ref = Frame.unmarshall(data);
-          _results = [];
-          for (_i = 0, _len = _ref.length; _i < _len; _i++) {
-            frame = _ref[_i];
-            switch (frame.command) {
-              case "CONNECTED":
-                if (typeof _this.debug === "function") {
-                  _this.debug("connected to server " + frame.headers.server);
-                }
-                _this.connected = true;
-                _this._setupHeartbeat(frame.headers);
-                _results.push(typeof _this.connectCallback === "function" ? _this.connectCallback(frame) : void 0);
-                break;
-              case "MESSAGE":
-                subscription = frame.headers.subscription;
-                onreceive = _this.subscriptions[subscription] || _this.onreceive;
-                if (onreceive) {
-                  client = _this;
-                  messageID = frame.headers["message-id"];
-                  frame.ack = function(headers) {
-                    if (headers == null) {
-                      headers = {};
-                    }
-                    return client.ack(messageID, subscription, headers);
-                  };
-                  frame.nack = function(headers) {
-                    if (headers == null) {
-                      headers = {};
-                    }
-                    return client.nack(messageID, subscription, headers);
-                  };
-                  _results.push(onreceive(frame));
-                } else {
-                  _results.push(typeof _this.debug === "function" ? _this.debug("Unhandled received MESSAGE: " + frame) : void 0);
-                }
-                break;
-              case "RECEIPT":
-                _results.push(typeof _this.onreceipt === "function" ? _this.onreceipt(frame) : void 0);
-                break;
-              case "ERROR":
-                _results.push(typeof errorCallback === "function" ? errorCallback(frame) : void 0);
-                break;
-              default:
-                _results.push(typeof _this.debug === "function" ? _this.debug("Unhandled frame: " + frame) : void 0);
-            }
-          }
-          return _results;
-        };
-      })(this);
-      this.ws.onclose = (function(_this) {
-        return function() {
-          var msg;
-          msg = "Whoops! Lost connection to " + _this.ws.url;
-          if (typeof _this.debug === "function") {
-            _this.debug(msg);
-          }
-          _this._cleanUp();
-          return typeof errorCallback === "function" ? errorCallback(msg) : void 0;
-        };
-      })(this);
-      return this.ws.onopen = (function(_this) {
-        return function() {
-          if (typeof _this.debug === "function") {
-            _this.debug('Web Socket Opened...');
-          }
-          headers["accept-version"] = Stomp.VERSIONS.supportedVersions();
-          headers["heart-beat"] = [_this.heartbeat.outgoing, _this.heartbeat.incoming].join(',');
-          return _this._transmit("CONNECT", headers);
-        };
-      })(this);
-    };
-
-    Client.prototype.disconnect = function(disconnectCallback) {
-      this._transmit("DISCONNECT");
-      this.ws.onclose = null;
-      this.ws.close();
-      this._cleanUp();
-      return typeof disconnectCallback === "function" ? disconnectCallback() : void 0;
-    };
-
-    Client.prototype._cleanUp = function() {
-      this.connected = false;
-      if (this.pinger) {
-        Stomp.clearInterval(this.pinger);
-      }
-      if (this.ponger) {
-        return Stomp.clearInterval(this.ponger);
-      }
-    };
-
-    Client.prototype.send = function(destination, headers, body) {
-      if (headers == null) {
-        headers = {};
-      }
-      if (body == null) {
-        body = '';
-      }
-      headers.destination = destination;
-      return this._transmit("SEND", headers, body);
-    };
-
-    Client.prototype.subscribe = function(destination, callback, headers) {
-      var client;
-      if (headers == null) {
-        headers = {};
-      }
-      if (!headers.id) {
-        headers.id = "sub-" + this.counter++;
-      }
-      headers.destination = destination;
-      this.subscriptions[headers.id] = callback;
-      this._transmit("SUBSCRIBE", headers);
-      client = this;
-      return {
-        id: headers.id,
-        unsubscribe: function() {
-          return client.unsubscribe(headers.id);
-        }
-      };
-    };
-
-    Client.prototype.unsubscribe = function(id) {
-      delete this.subscriptions[id];
-      return this._transmit("UNSUBSCRIBE", {
-        id: id
-      });
-    };
-
-    Client.prototype.begin = function(transaction) {
-      var client, txid;
-      txid = transaction || "tx-" + this.counter++;
-      this._transmit("BEGIN", {
-        transaction: txid
-      });
-      client = this;
-      return {
-        id: txid,
-        commit: function() {
-          return client.commit(txid);
-        },
-        abort: function() {
-          return client.abort(txid);
-        }
-      };
-    };
-
-    Client.prototype.commit = function(transaction) {
-      return this._transmit("COMMIT", {
-        transaction: transaction
-      });
-    };
-
-    Client.prototype.abort = function(transaction) {
-      return this._transmit("ABORT", {
-        transaction: transaction
-      });
-    };
-
-    Client.prototype.ack = function(messageID, subscription, headers) {
-      if (headers == null) {
-        headers = {};
-      }
-      headers["message-id"] = messageID;
-      headers.subscription = subscription;
-      return this._transmit("ACK", headers);
-    };
-
-    Client.prototype.nack = function(messageID, subscription, headers) {
-      if (headers == null) {
-        headers = {};
-      }
-      headers["message-id"] = messageID;
-      headers.subscription = subscription;
-      return this._transmit("NACK", headers);
-    };
-
-    return Client;
-
-  })();
-
-  Stomp = {
-    VERSIONS: {
-      V1_0: '1.0',
-      V1_1: '1.1',
-      V1_2: '1.2',
-      supportedVersions: function() {
-        return '1.1,1.0';
-      }
-    },
-    client: function(url, protocols) {
-      var klass, ws;
-      if (protocols == null) {
-        protocols = ['v10.stomp', 'v11.stomp'];
-      }
-      klass = Stomp.WebSocketClass || WebSocket;
-      ws = new klass(url, protocols);
-      return new Client(ws);
-    },
-    over: function(ws) {
-      return new Client(ws);
-    },
-    Frame: Frame
-  };
-
-  if (typeof window !== "undefined" && window !== null) {
-    Stomp.setInterval = function(interval, f) {
-      return window.setInterval(f, interval);
-    };
-    Stomp.clearInterval = function(id) {
-      return window.clearInterval(id);
-    };
-    window.Stomp = Stomp;
-  } else if (typeof exports !== "undefined" && exports !== null) {
-    exports.Stomp = Stomp;
-  } else {
-    self.Stomp = Stomp;
-  }
-
-}).call(this);

+ 131 - 0
complete/src/test/java/hello/GreetingIntegrationTests.java

@@ -0,0 +1,131 @@
+package hello;
+
+import static org.junit.Assert.*;
+
+import java.lang.reflect.Type;
+import java.util.ArrayList;
+import java.util.List;
+import java.util.concurrent.CountDownLatch;
+import java.util.concurrent.TimeUnit;
+import java.util.concurrent.atomic.AtomicReference;
+
+import org.junit.Before;
+import org.junit.Test;
+import org.junit.runner.RunWith;
+
+import org.springframework.boot.context.embedded.LocalServerPort;
+import org.springframework.boot.test.context.SpringBootTest;
+import org.springframework.messaging.converter.MappingJackson2MessageConverter;
+import org.springframework.messaging.simp.stomp.StompCommand;
+import org.springframework.messaging.simp.stomp.StompFrameHandler;
+import org.springframework.messaging.simp.stomp.StompHeaders;
+import org.springframework.messaging.simp.stomp.StompSession;
+import org.springframework.messaging.simp.stomp.StompSessionHandler;
+import org.springframework.messaging.simp.stomp.StompSessionHandlerAdapter;
+import org.springframework.test.context.junit4.SpringRunner;
+import org.springframework.web.socket.WebSocketHttpHeaders;
+import org.springframework.web.socket.client.standard.StandardWebSocketClient;
+import org.springframework.web.socket.messaging.WebSocketStompClient;
+import org.springframework.web.socket.sockjs.client.SockJsClient;
+import org.springframework.web.socket.sockjs.client.Transport;
+import org.springframework.web.socket.sockjs.client.WebSocketTransport;
+
+@RunWith(SpringRunner.class)
+@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
+public class GreetingIntegrationTests {
+
+    @LocalServerPort
+    private int port;
+
+    private SockJsClient sockJsClient;
+
+    private WebSocketStompClient stompClient;
+
+    private final WebSocketHttpHeaders headers = new WebSocketHttpHeaders();
+
+    @Before
+    public void setup() {
+        List<Transport> transports = new ArrayList<>();
+        transports.add(new WebSocketTransport(new StandardWebSocketClient()));
+        this.sockJsClient = new SockJsClient(transports);
+
+        this.stompClient = new WebSocketStompClient(sockJsClient);
+        this.stompClient.setMessageConverter(new MappingJackson2MessageConverter());
+    }
+
+    @Test
+    public void getGreeting() throws Exception {
+
+        final CountDownLatch latch = new CountDownLatch(1);
+        final AtomicReference<Throwable> failure = new AtomicReference<>();
+
+        StompSessionHandler handler = new TestSessionHandler(failure) {
+
+            @Override
+            public void afterConnected(final StompSession session, StompHeaders connectedHeaders) {
+                session.subscribe("/topic/greetings", new StompFrameHandler() {
+                    @Override
+                    public Type getPayloadType(StompHeaders headers) {
+                        return Greeting.class;
+                    }
+
+                    @Override
+                    public void handleFrame(StompHeaders headers, Object payload) {
+                        Greeting greeting = (Greeting) payload;
+                        try {
+                            assertEquals("Hello, Spring!", greeting.getContent());
+                        } catch (Throwable t) {
+                            failure.set(t);
+                        } finally {
+                            session.disconnect();
+                            latch.countDown();
+                        }
+                    }
+                });
+                try {
+                    session.send("/app/hello", new HelloMessage("Spring"));
+                } catch (Throwable t) {
+                    failure.set(t);
+                    latch.countDown();
+                }
+            }
+        };
+
+        this.stompClient.connect("ws://localhost:{port}/gs-guide-websocket", this.headers, handler, this.port);
+
+        if (latch.await(3, TimeUnit.SECONDS)) {
+            if (failure.get() != null) {
+                throw new AssertionError("", failure.get());
+            }
+        }
+        else {
+            fail("Greeting not received");
+        }
+
+    }
+
+    private class TestSessionHandler extends StompSessionHandlerAdapter {
+
+        private final AtomicReference<Throwable> failure;
+
+
+        public TestSessionHandler(AtomicReference<Throwable> failure) {
+            this.failure = failure;
+        }
+
+        @Override
+        public void handleFrame(StompHeaders headers, Object payload) {
+            this.failure.set(new Exception(headers.toString()));
+        }
+
+        @Override
+        public void handleException(StompSession s, StompCommand c, StompHeaders h, byte[] p, Throwable ex) {
+            this.failure.set(ex);
+        }
+
+        @Override
+        public void handleTransportError(StompSession session, Throwable ex) {
+            this.failure.set(ex);
+        }
+    }
+}

+ 0 - 0
initial/README.md


+ 7 - 3
initial/build.gradle

@@ -9,7 +9,6 @@ buildscript {
 
 apply plugin: 'java'
 apply plugin: 'eclipse'
-apply plugin: 'idea'
 apply plugin: 'spring-boot'
 
 jar {
@@ -25,7 +24,12 @@ repositories {
 
 dependencies {
     compile("org.springframework.boot:spring-boot-starter-websocket")
-    compile("org.springframework:spring-messaging")
-    testCompile("junit:junit")
+    compile("org.webjars:webjars-locator")
+    compile("org.webjars:sockjs-client:1.0.2")
+    compile("org.webjars:stomp-websocket:2.3.3")
+    compile("org.webjars:bootstrap:3.3.7")
+    compile("org.webjars:jquery:3.1.0")
+
+    testCompile("org.springframework.boot:spring-boot-starter-test")
 }
 

+ 30 - 3
initial/pom.xml

@@ -1,6 +1,6 @@
 <?xml version="1.0" encoding="UTF-8"?>
 <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
-    xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
+         xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
     <modelVersion>4.0.0</modelVersion>
 
     <groupId>org.springframework</groupId>
@@ -18,9 +18,36 @@
             <groupId>org.springframework.boot</groupId>
             <artifactId>spring-boot-starter-websocket</artifactId>
         </dependency>
+
+        <dependency>
+            <groupId>org.webjars</groupId>
+            <artifactId>webjars-locator</artifactId>
+        </dependency>
+        <dependency>
+            <groupId>org.webjars</groupId>
+            <artifactId>sockjs-client</artifactId>
+            <version>1.0.2</version>
+        </dependency>
+        <dependency>
+            <groupId>org.webjars</groupId>
+            <artifactId>stomp-websocket</artifactId>
+            <version>2.3.3</version>
+        </dependency>
         <dependency>
-            <groupId>org.springframework</groupId>
-            <artifactId>spring-messaging</artifactId>
+            <groupId>org.webjars</groupId>
+            <artifactId>bootstrap</artifactId>
+            <version>3.3.7</version>
+        </dependency>
+        <dependency>
+            <groupId>org.webjars</groupId>
+            <artifactId>jquery</artifactId>
+            <version>3.1.0</version>
+        </dependency>
+
+        <dependency>
+            <groupId>org.springframework.boot</groupId>
+            <artifactId>spring-boot-starter-test</artifactId>
+            <scope>test</scope>
         </dependency>
     </dependencies>
 

+ 0 - 15
initial/redeploy-tomcat.sh

@@ -1,15 +0,0 @@
-set -v
-
-mvn -DskipTests clean package
-
-# Change the line below to the location of Tomcat built from trunk
-TOMCAT=~/Applications/apache-tomcat-trunk/output/build
-
-rm -rf $TOMCAT/webapps/gs-websocket*
-
-cp target/gs-websocket.war $TOMCAT/webapps/
-
-$TOMCAT/bin/shutdown.sh
-sleep 3
-
-$TOMCAT/bin/startup.sh

+ 0 - 0
initial/src/main/java/hello/.gitignore


+ 0 - 38
initial/src/main/resources/log4j.xml

@@ -1,38 +0,0 @@
-<?xml version="1.0" encoding="UTF-8"?>
-<!DOCTYPE log4j:configuration PUBLIC "-//APACHE//DTD LOG4J 1.2//EN" "log4j.dtd">
-<log4j:configuration xmlns:log4j="http://jakarta.apache.org/log4j/">
-
-    <!-- Appenders -->
-    <appender name="console" class="org.apache.log4j.ConsoleAppender">
-        <param name="Target" value="System.out" />
-        <layout class="org.apache.log4j.PatternLayout">
-            <param name="ConversionPattern" value="%d{HH:mm:ss} [%t] %c{1} - %m%n" />
-        </layout>
-    </appender>
-    
-    <logger name="org.springframework.samples">
-        <level value="debug" />
-    </logger>
-
-    <logger name="org.springframework.messaging">
-        <level value="debug" />
-    </logger>
-
-    <logger name="org.springframework.web">
-        <level value="debug" />
-    </logger>
-
-    <logger name="org.springframework.web.socket">
-        <level value="debug" />
-    </logger>
-
-    <logger name="org.springframework.security">
-        <level value="warn" />
-    </logger>
-
-    <root>
-        <priority value="warn" />
-        <appender-ref ref="console" />
-    </root>
-    
-</log4j:configuration>

+ 14 - 0
initial/src/main/resources/static/main.css

@@ -0,0 +1,14 @@
+body {
+    background-color: #f5f5f5;
+}
+
+#main-content {
+    max-width: 940px;
+    padding: 2em 3em;
+    margin: 0 auto 20px;
+    background-color: #fff;
+    border: 1px solid #e5e5e5;
+    -webkit-border-radius: 5px;
+    -moz-border-radius: 5px;
+    border-radius: 5px;
+}

Failā izmaiņas netiks attēlotas, jo tās ir par lielu
+ 0 - 24
initial/src/main/resources/static/sockjs-0.3.4.js


+ 0 - 475
initial/src/main/resources/static/stomp.js

@@ -1,475 +0,0 @@
-// Generated by CoffeeScript 1.7.1
-
-/*
-   Stomp Over WebSocket http://www.jmesnil.net/stomp-websocket/doc/ | Apache License V2.0
-
-   Copyright (C) 2010-2013 [Jeff Mesnil](http://jmesnil.net/)
-   Copyright (C) 2012 [FuseSource, Inc.](http://fusesource.com)
- */
-
-(function() {
-  var Byte, Client, Frame, Stomp,
-    __hasProp = {}.hasOwnProperty,
-    __slice = [].slice;
-
-  Byte = {
-    LF: '\x0A',
-    NULL: '\x00'
-  };
-
-  Frame = (function() {
-    var unmarshallSingle;
-
-    function Frame(command, headers, body) {
-      this.command = command;
-      this.headers = headers != null ? headers : {};
-      this.body = body != null ? body : '';
-    }
-
-    Frame.prototype.toString = function() {
-      var lines, name, value, _ref;
-      lines = [this.command];
-      _ref = this.headers;
-      for (name in _ref) {
-        if (!__hasProp.call(_ref, name)) continue;
-        value = _ref[name];
-        lines.push("" + name + ":" + value);
-      }
-      if (this.body) {
-        lines.push("content-length:" + (Frame.sizeOfUTF8(this.body)));
-      }
-      lines.push(Byte.LF + this.body);
-      return lines.join(Byte.LF);
-    };
-
-    Frame.sizeOfUTF8 = function(s) {
-      if (s) {
-        return encodeURI(s).split(/%..|./).length - 1;
-      } else {
-        return 0;
-      }
-    };
-
-    unmarshallSingle = function(data) {
-      var body, chr, command, divider, headerLines, headers, i, idx, len, line, start, trim, _i, _j, _len, _ref, _ref1;
-      divider = data.search(RegExp("" + Byte.LF + Byte.LF));
-      headerLines = data.substring(0, divider).split(Byte.LF);
-      command = headerLines.shift();
-      headers = {};
-      trim = function(str) {
-        return str.replace(/^\s+|\s+$/g, '');
-      };
-      _ref = headerLines.reverse();
-      for (_i = 0, _len = _ref.length; _i < _len; _i++) {
-        line = _ref[_i];
-        idx = line.indexOf(':');
-        headers[trim(line.substring(0, idx))] = trim(line.substring(idx + 1));
-      }
-      body = '';
-      start = divider + 2;
-      if (headers['content-length']) {
-        len = parseInt(headers['content-length']);
-        body = ('' + data).substring(start, start + len);
-      } else {
-        chr = null;
-        for (i = _j = start, _ref1 = data.length; start <= _ref1 ? _j < _ref1 : _j > _ref1; i = start <= _ref1 ? ++_j : --_j) {
-          chr = data.charAt(i);
-          if (chr === Byte.NULL) {
-            break;
-          }
-          body += chr;
-        }
-      }
-      return new Frame(command, headers, body);
-    };
-
-    Frame.unmarshall = function(datas) {
-      var data;
-      return (function() {
-        var _i, _len, _ref, _results;
-        _ref = datas.split(RegExp("" + Byte.NULL + Byte.LF + "*"));
-        _results = [];
-        for (_i = 0, _len = _ref.length; _i < _len; _i++) {
-          data = _ref[_i];
-          if ((data != null ? data.length : void 0) > 0) {
-            _results.push(unmarshallSingle(data));
-          }
-        }
-        return _results;
-      })();
-    };
-
-    Frame.marshall = function(command, headers, body) {
-      var frame;
-      frame = new Frame(command, headers, body);
-      return frame.toString() + Byte.NULL;
-    };
-
-    return Frame;
-
-  })();
-
-  Client = (function() {
-    var now;
-
-    function Client(ws) {
-      this.ws = ws;
-      this.ws.binaryType = "arraybuffer";
-      this.counter = 0;
-      this.connected = false;
-      this.heartbeat = {
-        outgoing: 10000,
-        incoming: 10000
-      };
-      this.maxWebSocketFrameSize = 16 * 1024;
-      this.subscriptions = {};
-    }
-
-    Client.prototype.debug = function(message) {
-      var _ref;
-      return typeof window !== "undefined" && window !== null ? (_ref = window.console) != null ? _ref.log(message) : void 0 : void 0;
-    };
-
-    now = function() {
-      return Date.now || new Date().valueOf;
-    };
-
-    Client.prototype._transmit = function(command, headers, body) {
-      var out;
-      out = Frame.marshall(command, headers, body);
-      if (typeof this.debug === "function") {
-        this.debug(">>> " + out);
-      }
-      while (true) {
-        if (out.length > this.maxWebSocketFrameSize) {
-          this.ws.send(out.substring(0, this.maxWebSocketFrameSize));
-          out = out.substring(this.maxWebSocketFrameSize);
-          if (typeof this.debug === "function") {
-            this.debug("remaining = " + out.length);
-          }
-        } else {
-          return this.ws.send(out);
-        }
-      }
-    };
-
-    Client.prototype._setupHeartbeat = function(headers) {
-      var serverIncoming, serverOutgoing, ttl, v, _ref, _ref1;
-      if ((_ref = headers.version) !== Stomp.VERSIONS.V1_1 && _ref !== Stomp.VERSIONS.V1_2) {
-        return;
-      }
-      _ref1 = (function() {
-        var _i, _len, _ref1, _results;
-        _ref1 = headers['heart-beat'].split(",");
-        _results = [];
-        for (_i = 0, _len = _ref1.length; _i < _len; _i++) {
-          v = _ref1[_i];
-          _results.push(parseInt(v));
-        }
-        return _results;
-      })(), serverOutgoing = _ref1[0], serverIncoming = _ref1[1];
-      if (!(this.heartbeat.outgoing === 0 || serverIncoming === 0)) {
-        ttl = Math.max(this.heartbeat.outgoing, serverIncoming);
-        if (typeof this.debug === "function") {
-          this.debug("send PING every " + ttl + "ms");
-        }
-        this.pinger = Stomp.setInterval(ttl, (function(_this) {
-          return function() {
-            _this.ws.send(Byte.LF);
-            return typeof _this.debug === "function" ? _this.debug(">>> PING") : void 0;
-          };
-        })(this));
-      }
-      if (!(this.heartbeat.incoming === 0 || serverOutgoing === 0)) {
-        ttl = Math.max(this.heartbeat.incoming, serverOutgoing);
-        if (typeof this.debug === "function") {
-          this.debug("check PONG every " + ttl + "ms");
-        }
-        return this.ponger = Stomp.setInterval(ttl, (function(_this) {
-          return function() {
-            var delta;
-            delta = now() - _this.serverActivity;
-            if (delta > ttl * 2) {
-              if (typeof _this.debug === "function") {
-                _this.debug("did not receive server activity for the last " + delta + "ms");
-              }
-              return _this.ws.close();
-            }
-          };
-        })(this));
-      }
-    };
-
-    Client.prototype._parseConnect = function() {
-      var args, connectCallback, errorCallback, headers;
-      args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
-      headers = {};
-      switch (args.length) {
-        case 2:
-          headers = args[0], connectCallback = args[1];
-          break;
-        case 3:
-          if (args[1] instanceof Function) {
-            headers = args[0], connectCallback = args[1], errorCallback = args[2];
-          } else {
-            headers.login = args[0], headers.passcode = args[1], connectCallback = args[2];
-          }
-          break;
-        case 4:
-          headers.login = args[0], headers.passcode = args[1], connectCallback = args[2], errorCallback = args[3];
-          break;
-        default:
-          headers.login = args[0], headers.passcode = args[1], connectCallback = args[2], errorCallback = args[3], headers.host = args[4];
-      }
-      return [headers, connectCallback, errorCallback];
-    };
-
-    Client.prototype.connect = function() {
-      var args, errorCallback, headers, out;
-      args = 1 <= arguments.length ? __slice.call(arguments, 0) : [];
-      out = this._parseConnect.apply(this, args);
-      headers = out[0], this.connectCallback = out[1], errorCallback = out[2];
-      if (typeof this.debug === "function") {
-        this.debug("Opening Web Socket...");
-      }
-      this.ws.onmessage = (function(_this) {
-        return function(evt) {
-          var arr, c, client, data, frame, messageID, onreceive, subscription, _i, _len, _ref, _results;
-          data = typeof ArrayBuffer !== 'undefined' && evt.data instanceof ArrayBuffer ? (arr = new Uint8Array(evt.data), typeof _this.debug === "function" ? _this.debug("--- got data length: " + arr.length) : void 0, ((function() {
-            var _i, _len, _results;
-            _results = [];
-            for (_i = 0, _len = arr.length; _i < _len; _i++) {
-              c = arr[_i];
-              _results.push(String.fromCharCode(c));
-            }
-            return _results;
-          })()).join('')) : evt.data;
-          _this.serverActivity = now();
-          if (data === Byte.LF) {
-            if (typeof _this.debug === "function") {
-              _this.debug("<<< PONG");
-            }
-            return;
-          }
-          if (typeof _this.debug === "function") {
-            _this.debug("<<< " + data);
-          }
-          _ref = Frame.unmarshall(data);
-          _results = [];
-          for (_i = 0, _len = _ref.length; _i < _len; _i++) {
-            frame = _ref[_i];
-            switch (frame.command) {
-              case "CONNECTED":
-                if (typeof _this.debug === "function") {
-                  _this.debug("connected to server " + frame.headers.server);
-                }
-                _this.connected = true;
-                _this._setupHeartbeat(frame.headers);
-                _results.push(typeof _this.connectCallback === "function" ? _this.connectCallback(frame) : void 0);
-                break;
-              case "MESSAGE":
-                subscription = frame.headers.subscription;
-                onreceive = _this.subscriptions[subscription] || _this.onreceive;
-                if (onreceive) {
-                  client = _this;
-                  messageID = frame.headers["message-id"];
-                  frame.ack = function(headers) {
-                    if (headers == null) {
-                      headers = {};
-                    }
-                    return client.ack(messageID, subscription, headers);
-                  };
-                  frame.nack = function(headers) {
-                    if (headers == null) {
-                      headers = {};
-                    }
-                    return client.nack(messageID, subscription, headers);
-                  };
-                  _results.push(onreceive(frame));
-                } else {
-                  _results.push(typeof _this.debug === "function" ? _this.debug("Unhandled received MESSAGE: " + frame) : void 0);
-                }
-                break;
-              case "RECEIPT":
-                _results.push(typeof _this.onreceipt === "function" ? _this.onreceipt(frame) : void 0);
-                break;
-              case "ERROR":
-                _results.push(typeof errorCallback === "function" ? errorCallback(frame) : void 0);
-                break;
-              default:
-                _results.push(typeof _this.debug === "function" ? _this.debug("Unhandled frame: " + frame) : void 0);
-            }
-          }
-          return _results;
-        };
-      })(this);
-      this.ws.onclose = (function(_this) {
-        return function() {
-          var msg;
-          msg = "Whoops! Lost connection to " + _this.ws.url;
-          if (typeof _this.debug === "function") {
-            _this.debug(msg);
-          }
-          _this._cleanUp();
-          return typeof errorCallback === "function" ? errorCallback(msg) : void 0;
-        };
-      })(this);
-      return this.ws.onopen = (function(_this) {
-        return function() {
-          if (typeof _this.debug === "function") {
-            _this.debug('Web Socket Opened...');
-          }
-          headers["accept-version"] = Stomp.VERSIONS.supportedVersions();
-          headers["heart-beat"] = [_this.heartbeat.outgoing, _this.heartbeat.incoming].join(',');
-          return _this._transmit("CONNECT", headers);
-        };
-      })(this);
-    };
-
-    Client.prototype.disconnect = function(disconnectCallback) {
-      this._transmit("DISCONNECT");
-      this.ws.onclose = null;
-      this.ws.close();
-      this._cleanUp();
-      return typeof disconnectCallback === "function" ? disconnectCallback() : void 0;
-    };
-
-    Client.prototype._cleanUp = function() {
-      this.connected = false;
-      if (this.pinger) {
-        Stomp.clearInterval(this.pinger);
-      }
-      if (this.ponger) {
-        return Stomp.clearInterval(this.ponger);
-      }
-    };
-
-    Client.prototype.send = function(destination, headers, body) {
-      if (headers == null) {
-        headers = {};
-      }
-      if (body == null) {
-        body = '';
-      }
-      headers.destination = destination;
-      return this._transmit("SEND", headers, body);
-    };
-
-    Client.prototype.subscribe = function(destination, callback, headers) {
-      var client;
-      if (headers == null) {
-        headers = {};
-      }
-      if (!headers.id) {
-        headers.id = "sub-" + this.counter++;
-      }
-      headers.destination = destination;
-      this.subscriptions[headers.id] = callback;
-      this._transmit("SUBSCRIBE", headers);
-      client = this;
-      return {
-        id: headers.id,
-        unsubscribe: function() {
-          return client.unsubscribe(headers.id);
-        }
-      };
-    };
-
-    Client.prototype.unsubscribe = function(id) {
-      delete this.subscriptions[id];
-      return this._transmit("UNSUBSCRIBE", {
-        id: id
-      });
-    };
-
-    Client.prototype.begin = function(transaction) {
-      var client, txid;
-      txid = transaction || "tx-" + this.counter++;
-      this._transmit("BEGIN", {
-        transaction: txid
-      });
-      client = this;
-      return {
-        id: txid,
-        commit: function() {
-          return client.commit(txid);
-        },
-        abort: function() {
-          return client.abort(txid);
-        }
-      };
-    };
-
-    Client.prototype.commit = function(transaction) {
-      return this._transmit("COMMIT", {
-        transaction: transaction
-      });
-    };
-
-    Client.prototype.abort = function(transaction) {
-      return this._transmit("ABORT", {
-        transaction: transaction
-      });
-    };
-
-    Client.prototype.ack = function(messageID, subscription, headers) {
-      if (headers == null) {
-        headers = {};
-      }
-      headers["message-id"] = messageID;
-      headers.subscription = subscription;
-      return this._transmit("ACK", headers);
-    };
-
-    Client.prototype.nack = function(messageID, subscription, headers) {
-      if (headers == null) {
-        headers = {};
-      }
-      headers["message-id"] = messageID;
-      headers.subscription = subscription;
-      return this._transmit("NACK", headers);
-    };
-
-    return Client;
-
-  })();
-
-  Stomp = {
-    VERSIONS: {
-      V1_0: '1.0',
-      V1_1: '1.1',
-      V1_2: '1.2',
-      supportedVersions: function() {
-        return '1.1,1.0';
-      }
-    },
-    client: function(url, protocols) {
-      var klass, ws;
-      if (protocols == null) {
-        protocols = ['v10.stomp', 'v11.stomp'];
-      }
-      klass = Stomp.WebSocketClass || WebSocket;
-      ws = new klass(url, protocols);
-      return new Client(ws);
-    },
-    over: function(ws) {
-      return new Client(ws);
-    },
-    Frame: Frame
-  };
-
-  if (typeof window !== "undefined" && window !== null) {
-    Stomp.setInterval = function(interval, f) {
-      return window.setInterval(f, interval);
-    };
-    Stomp.clearInterval = function(id) {
-      return window.clearInterval(id);
-    };
-    window.Stomp = Stomp;
-  } else if (typeof exports !== "undefined" && exports !== null) {
-    exports.Stomp = Stomp;
-  } else {
-    self.Stomp = Stomp;
-  }
-
-}).call(this);

Daži faili netika attēloti, jo izmaiņu fails ir pārāk liels