├── LICENSE ├── README.md ├── pom.xml └── src └── main ├── java └── com │ └── example │ └── messaging │ ├── AppConfig.java │ └── Starter.java └── javascript ├── index.html └── stomp.js /LICENSE: -------------------------------------------------------------------------------- 1 | 2 | Apache License 3 | Version 2.0, January 2004 4 | http://www.apache.org/licenses/ 5 | 6 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION 7 | 8 | 1. Definitions. 9 | 10 | "License" shall mean the terms and conditions for use, reproduction, 11 | and distribution as defined by Sections 1 through 9 of this document. 12 | 13 | "Licensor" shall mean the copyright owner or entity authorized by 14 | the copyright owner that is granting the License. 15 | 16 | "Legal Entity" shall mean the union of the acting entity and all 17 | other entities that control, are controlled by, or are under common 18 | control with that entity. For the purposes of this definition, 19 | "control" means (i) the power, direct or indirect, to cause the 20 | direction or management of such entity, whether by contract or 21 | otherwise, or (ii) ownership of fifty percent (50%) or more of the 22 | outstanding shares, or (iii) beneficial ownership of such entity. 23 | 24 | "You" (or "Your") shall mean an individual or Legal Entity 25 | exercising permissions granted by this License. 26 | 27 | "Source" form shall mean the preferred form for making modifications, 28 | including but not limited to software source code, documentation 29 | source, and configuration files. 30 | 31 | "Object" form shall mean any form resulting from mechanical 32 | transformation or translation of a Source form, including but 33 | not limited to compiled object code, generated documentation, 34 | and conversions to other media types. 35 | 36 | "Work" shall mean the work of authorship, whether in Source or 37 | Object form, made available under the License, as indicated by a 38 | copyright notice that is included in or attached to the work 39 | (an example is provided in the Appendix below). 40 | 41 | "Derivative Works" shall mean any work, whether in Source or Object 42 | form, that is based on (or derived from) the Work and for which the 43 | editorial revisions, annotations, elaborations, or other modifications 44 | represent, as a whole, an original work of authorship. For the purposes 45 | of this License, Derivative Works shall not include works that remain 46 | separable from, or merely link (or bind by name) to the interfaces of, 47 | the Work and Derivative Works thereof. 48 | 49 | "Contribution" shall mean any work of authorship, including 50 | the original version of the Work and any modifications or additions 51 | to that Work or Derivative Works thereof, that is intentionally 52 | submitted to Licensor for inclusion in the Work by the copyright owner 53 | or by an individual or Legal Entity authorized to submit on behalf of 54 | the copyright owner. For the purposes of this definition, "submitted" 55 | means any form of electronic, verbal, or written communication sent 56 | to the Licensor or its representatives, including but not limited to 57 | communication on electronic mailing lists, source code control systems, 58 | and issue tracking systems that are managed by, or on behalf of, the 59 | Licensor for the purpose of discussing and improving the Work, but 60 | excluding communication that is conspicuously marked or otherwise 61 | designated in writing by the copyright owner as "Not a Contribution." 62 | 63 | "Contributor" shall mean Licensor and any individual or Legal Entity 64 | on behalf of whom a Contribution has been received by Licensor and 65 | subsequently incorporated within the Work. 66 | 67 | 2. Grant of Copyright License. Subject to the terms and conditions of 68 | this License, each Contributor hereby grants to You a perpetual, 69 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 70 | copyright license to reproduce, prepare Derivative Works of, 71 | publicly display, publicly perform, sublicense, and distribute the 72 | Work and such Derivative Works in Source or Object form. 73 | 74 | 3. Grant of Patent License. Subject to the terms and conditions of 75 | this License, each Contributor hereby grants to You a perpetual, 76 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable 77 | (except as stated in this section) patent license to make, have made, 78 | use, offer to sell, sell, import, and otherwise transfer the Work, 79 | where such license applies only to those patent claims licensable 80 | by such Contributor that are necessarily infringed by their 81 | Contribution(s) alone or by combination of their Contribution(s) 82 | with the Work to which such Contribution(s) was submitted. If You 83 | institute patent litigation against any entity (including a 84 | cross-claim or counterclaim in a lawsuit) alleging that the Work 85 | or a Contribution incorporated within the Work constitutes direct 86 | or contributory patent infringement, then any patent licenses 87 | granted to You under this License for that Work shall terminate 88 | as of the date such litigation is filed. 89 | 90 | 4. Redistribution. You may reproduce and distribute copies of the 91 | Work or Derivative Works thereof in any medium, with or without 92 | modifications, and in Source or Object form, provided that You 93 | meet the following conditions: 94 | 95 | (a) You must give any other recipients of the Work or 96 | Derivative Works a copy of this License; and 97 | 98 | (b) You must cause any modified files to carry prominent notices 99 | stating that You changed the files; and 100 | 101 | (c) You must retain, in the Source form of any Derivative Works 102 | that You distribute, all copyright, patent, trademark, and 103 | attribution notices from the Source form of the Work, 104 | excluding those notices that do not pertain to any part of 105 | the Derivative Works; and 106 | 107 | (d) If the Work includes a "NOTICE" text file as part of its 108 | distribution, then any Derivative Works that You distribute must 109 | include a readable copy of the attribution notices contained 110 | within such NOTICE file, excluding those notices that do not 111 | pertain to any part of the Derivative Works, in at least one 112 | of the following places: within a NOTICE text file distributed 113 | as part of the Derivative Works; within the Source form or 114 | documentation, if provided along with the Derivative Works; or, 115 | within a display generated by the Derivative Works, if and 116 | wherever such third-party notices normally appear. The contents 117 | of the NOTICE file are for informational purposes only and 118 | do not modify the License. You may add Your own attribution 119 | notices within Derivative Works that You distribute, alongside 120 | or as an addendum to the NOTICE text from the Work, provided 121 | that such additional attribution notices cannot be construed 122 | as modifying the License. 123 | 124 | You may add Your own copyright statement to Your modifications and 125 | may provide additional or different license terms and conditions 126 | for use, reproduction, or distribution of Your modifications, or 127 | for any such Derivative Works as a whole, provided Your use, 128 | reproduction, and distribution of the Work otherwise complies with 129 | the conditions stated in this License. 130 | 131 | 5. Submission of Contributions. Unless You explicitly state otherwise, 132 | any Contribution intentionally submitted for inclusion in the Work 133 | by You to the Licensor shall be under the terms and conditions of 134 | this License, without any additional terms or conditions. 135 | Notwithstanding the above, nothing herein shall supersede or modify 136 | the terms of any separate license agreement you may have executed 137 | with Licensor regarding such Contributions. 138 | 139 | 6. Trademarks. This License does not grant permission to use the trade 140 | names, trademarks, service marks, or product names of the Licensor, 141 | except as required for reasonable and customary use in describing the 142 | origin of the Work and reproducing the content of the NOTICE file. 143 | 144 | 7. Disclaimer of Warranty. Unless required by applicable law or 145 | agreed to in writing, Licensor provides the Work (and each 146 | Contributor provides its Contributions) on an "AS IS" BASIS, 147 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or 148 | implied, including, without limitation, any warranties or conditions 149 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A 150 | PARTICULAR PURPOSE. You are solely responsible for determining the 151 | appropriateness of using or redistributing the Work and assume any 152 | risks associated with Your exercise of permissions under this License. 153 | 154 | 8. Limitation of Liability. In no event and under no legal theory, 155 | whether in tort (including negligence), contract, or otherwise, 156 | unless required by applicable law (such as deliberate and grossly 157 | negligent acts) or agreed to in writing, shall any Contributor be 158 | liable to You for damages, including any direct, indirect, special, 159 | incidental, or consequential damages of any character arising as a 160 | result of this License or out of the use or inability to use the 161 | Work (including but not limited to damages for loss of goodwill, 162 | work stoppage, computer failure or malfunction, or any and all 163 | other commercial damages or losses), even if such Contributor 164 | has been advised of the possibility of such damages. 165 | 166 | 9. Accepting Warranty or Additional Liability. While redistributing 167 | the Work or Derivative Works thereof, You may choose to offer, 168 | and charge a fee for, acceptance of support, warranty, indemnity, 169 | or other liability obligations and/or rights consistent with this 170 | License. However, in accepting such obligations, You may act only 171 | on Your own behalf and on Your sole responsibility, not on behalf 172 | of any other Contributor, and only if You agree to indemnify, 173 | defend, and hold each Contributor harmless for any liability 174 | incurred by, or claims asserted against, such Contributor by reason 175 | of your accepting any such warranty or additional liability. 176 | 177 | END OF TERMS AND CONDITIONS 178 | 179 | APPENDIX: How to apply the Apache License to your work. 180 | 181 | To apply the Apache License to your work, attach the following 182 | boilerplate notice, with the fields enclosed by brackets "[]" 183 | replaced with your own identifying information. (Don't include 184 | the brackets!) The text should be enclosed in the appropriate 185 | comment syntax for the file format. We also recommend that a 186 | file or class name and description of purpose be included on the 187 | same "printed page" as the copyright notice for easier 188 | identification within third-party archives. 189 | 190 | Copyright [yyyy] [name of copyright owner] 191 | 192 | Licensed under the Apache License, Version 2.0 (the "License"); 193 | you may not use this file except in compliance with the License. 194 | You may obtain a copy of the License at 195 | 196 | http://www.apache.org/licenses/LICENSE-2.0 197 | 198 | Unless required by applicable law or agreed to in writing, software 199 | distributed under the License is distributed on an "AS IS" BASIS, 200 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 201 | See the License for the specific language governing permissions and 202 | limitations under the License. 203 | 204 | -- activemq-web 205 | ========================================================================= 206 | == For the behaviour.js library == 207 | ========================================================================= 208 | 209 | Copyright (c) 2005, Ben Nolan 210 | All rights reserved. 211 | 212 | Redistribution and use in source and binary forms, with or without 213 | modification, are permitted provided that the following conditions are 214 | met: 215 | 216 | * Redistributions of source code must retain the above copyright 217 | notice, this list of conditions and the following disclaimer. 218 | * Redistributions in binary form must reproduce the above 219 | copyright notice, this list of conditions and the following 220 | disclaimer in the documentation and/or other materials provided 221 | with the distribution. 222 | * Neither the name of the Ben Nolan nor the names of its 223 | contributors may be used to endorse or promote products derived 224 | from this software without specific prior written permission. 225 | 226 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 227 | "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 228 | LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 229 | A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 230 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 231 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 232 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 233 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 234 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 235 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 236 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 237 | 238 | ========================================================================= 239 | == For the prototype.js library == 240 | ========================================================================= 241 | 242 | Copyright (c) 2005 Sam Stephenson 243 | 244 | Permission is hereby granted, free of charge, to any person obtaining a copy 245 | of this software and associated documentation files (the "Software"), to deal 246 | in the Software without restriction, including without limitation the rights 247 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 248 | copies of the Software, and to permit persons to whom the Software is 249 | furnished to do so, subject to the following conditions: 250 | 251 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 252 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 253 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 254 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 255 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 256 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 257 | SOFTWARE. 258 | 259 | 260 | ==================================================================== 261 | == Licenses for non-apache libraries included in this assembly == 262 | ==================================================================== 263 | 264 | jetty 265 | jmdns 266 | mx4j 267 | spring 268 | tanuki wrapper 269 | xmlpull 270 | xstream 271 | 272 | ========================================================================= 273 | == Jetty is licensed under the Apache License Version 2.0 == 274 | ========================================================================= 275 | ========================================================================= 276 | == jmdns is licensed under the Apache License Version 2.0 == 277 | ========================================================================= 278 | ========================================================================= 279 | == For the mx4j, mx4j-remote, and mx4j-tools library == 280 | ========================================================================= 281 | 282 | The MX4J License, Version 1.0 283 | 284 | Copyright (c) 2001-2004 by the MX4J contributors. All rights reserved. 285 | 286 | Redistribution and use in source and binary forms, with or without 287 | modification, are permitted provided that the following conditions 288 | are met: 289 | 290 | 1. Redistributions of source code must retain the above copyright 291 | notice, this list of conditions and the following disclaimer. 292 | 293 | 2. Redistributions in binary form must reproduce the above copyright 294 | notice, this list of conditions and the following disclaimer in 295 | the documentation and/or other materials provided with the 296 | distribution. 297 | 298 | 3. The end-user documentation included with the redistribution, 299 | if any, must include the following acknowledgment: 300 | "This product includes software developed by the 301 | MX4J project (http://mx4j.sourceforge.net)." 302 | Alternately, this acknowledgment may appear in the software itself, 303 | if and wherever such third-party acknowledgments normally appear. 304 | 305 | 4. The name "MX4J" must not be used to endorse or promote 306 | products derived from this software without prior written 307 | permission. 308 | For written permission, please contact 309 | biorn_steedom [at] users [dot] sourceforge [dot] net 310 | 311 | 5. Products derived from this software may not be called "MX4J", 312 | nor may "MX4J" appear in their name, without prior written 313 | permission of Simone Bordet. 314 | 315 | THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED 316 | WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 317 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 318 | DISCLAIMED. IN NO EVENT SHALL THE MX4J CONTRIBUTORS 319 | BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 320 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 321 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF 322 | USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 323 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, 324 | OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 325 | OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 326 | SUCH DAMAGE. 327 | ==================================================================== 328 | 329 | This software consists of voluntary contributions made by many 330 | individuals on behalf of the MX4J project. For more information on 331 | MX4J, please see 332 | the MX4J website. 333 | 334 | 335 | ========================================================================= 336 | == Spring is licensed under the Apache License Version 2.0 == 337 | ========================================================================= 338 | 339 | ========================================================================= 340 | == For the Tanuki Software libraries == 341 | ========================================================================= 342 | Copyright (c) 1999, 2004 Tanuki Software 343 | 344 | Permission is hereby granted, free of charge, to any person 345 | obtaining a copy of the Java Service Wrapper and associated 346 | documentation files (the "Software"), to deal in the Software 347 | without restriction, including without limitation the rights 348 | to use, copy, modify, merge, publish, distribute, sub-license, 349 | and/or sell copies of the Software, and to permit persons to 350 | whom the Software is furnished to do so, subject to the 351 | following conditions: 352 | 353 | The above copyright notice and this permission notice shall be 354 | included in all copies or substantial portions of the Software. 355 | 356 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 357 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES 358 | OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND 359 | NON-INFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT 360 | HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, 361 | WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 362 | FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 363 | OTHER DEALINGS IN THE SOFTWARE. 364 | 365 | 366 | Portions of the Software have been derived from source code 367 | developed by Silver Egg Technology under the following license: 368 | 369 | Copyright (c) 2001 Silver Egg Technology 370 | 371 | Permission is hereby granted, free of charge, to any person 372 | obtaining a copy of this software and associated documentation 373 | files (the "Software"), to deal in the Software without 374 | restriction, including without limitation the rights to use, 375 | copy, modify, merge, publish, distribute, sub-license, and/or 376 | sell copies of the Software, and to permit persons to whom the 377 | Software is furnished to do so, subject to the following 378 | conditions: 379 | 380 | The above copyright notice and this permission notice shall be 381 | included in all copies or substantial portions of the Software. 382 | 383 | 384 | ========================================================================= 385 | == For the xmlpull library == 386 | ========================================================================= 387 | 388 | XMLPULL API IS FREE 389 | ------------------- 390 | 391 | All of the XMLPULL API source code, compiled code, and documentation 392 | contained in this distribution *except* for tests (see separate LICENSE_TESTS.txt) 393 | are in the Public Domain. 394 | 395 | XMLPULL API comes with NO WARRANTY or guarantee of fitness for any purpose. 396 | 397 | Initial authors: 398 | 399 | Stefan Haustein 400 | Aleksander Slominski 401 | 402 | 2001-12-12 403 | 404 | ========================================================================= 405 | == For the xstream library == 406 | ========================================================================= 407 | 408 | (BSD Style License) 409 | 410 | Copyright (c) 2003-2004, Joe Walnes 411 | All rights reserved. 412 | 413 | Redistribution and use in source and binary forms, with or without 414 | modification, are permitted provided that the following conditions are met: 415 | 416 | Redistributions of source code must retain the above copyright notice, this list of 417 | conditions and the following disclaimer. Redistributions in binary form must reproduce 418 | the above copyright notice, this list of conditions and the following disclaimer in 419 | the documentation and/or other materials provided with the distribution. 420 | 421 | Neither the name of XStream nor the names of its contributors may be used to endorse 422 | or promote products derived from this software without specific prior written 423 | permission. 424 | 425 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY 426 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 427 | OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 428 | SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, 429 | INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED 430 | TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR 431 | BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 432 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY 433 | WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH 434 | DAMAGE. 435 | 436 | ========================================================================= 437 | == For jaxb-api and jaxb-impl (CDDL) == 438 | == Source code is at java.net == 439 | ========================================================================= 440 | 441 | COMMON DEVELOPMENT AND DISTRIBUTION LICENSE (CDDL) 442 | Version 1.0 443 | 444 | * 445 | 446 | 1. Definitions. 447 | o 448 | 449 | 1.1. “Contributor” means each individual or entity that creates or contributes to the creation of Modifications. 450 | o 451 | 452 | 1.2. “Contributor Version” means the combination of the Original Software, prior Modifications used by a Contributor (if any), and the Modifications made by that particular Contributor. 453 | o 454 | 455 | 1.3. “Covered Software” means (a) the Original Software, or (b) Modifications, or (c) the combination of files containing Original Software with files containing Modifications, in each case including portions thereof. 456 | o 457 | 458 | 1.4. “Executable” means the Covered Software in any form other than Source Code. 459 | o 460 | 461 | 1.5. “Initial Developer” means the individual or entity that first makes Original Software available under this License. 462 | o 463 | 464 | 1.6. “Larger Work” means a work which combines Covered Software or portions thereof with code not governed by the terms of this License. 465 | o 466 | 467 | 1.7. “License” means this document. 468 | o 469 | 470 | 1.8. “Licensable” means having the right to grant, to the maximum extent possible, whether at the time of the initial grant or subsequently acquired, any and all of the rights conveyed herein. 471 | o 472 | 473 | 1.9. “Modifications” means the Source Code and Executable form of any of the following: 474 | + 475 | 476 | A. Any file that results from an addition to, deletion from or modification of the contents of a file containing Original Software or previous Modifications; 477 | + 478 | 479 | B. Any new file that contains any part of the Original Software or previous Modification; or 480 | + 481 | 482 | C. Any new file that is contributed or otherwise made available under the terms of this License. 483 | o 484 | 485 | 1.10. “Original Software” means the Source Code and Executable form of computer software code that is originally released under this License. 486 | o 487 | 488 | 1.11. “Patent Claims” means any patent claim(s), now owned or hereafter acquired, including without limitation, method, process, and apparatus claims, in any patent Licensable by grantor. 489 | o 490 | 491 | 1.12. “Source Code” means (a) the common form of computer software code in which modifications are made and (b) associated documentation included in or with such code. 492 | o 493 | 494 | 1.13. “You” (or “Your”) means an individual or a legal entity exercising rights under, and complying with all of the terms of, this License. For legal entities, “You” includes any entity which controls, is controlled by, or is under common control with You. For purposes of this definition, “control” means (a) the power, direct or indirect, to cause the direction or management of such entity, whether by contract or otherwise, or (b) ownership of more than fifty percent (50%) of the outstanding shares or beneficial ownership of such entity. 495 | * 496 | 497 | 2. License Grants. 498 | o 499 | 500 | 2.1. The Initial Developer Grant. 501 | 502 | Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, the Initial Developer hereby grants You a world-wide, royalty-free, non-exclusive license: 503 | + 504 | 505 | (a) under intellectual property rights (other than patent or trademark) Licensable by Initial Developer, to use, reproduce, modify, display, perform, sublicense and distribute the Original Software (or portions thereof), with or without Modifications, and/or as part of a Larger Work; and 506 | + 507 | 508 | (b) under Patent Claims infringed by the making, using or selling of Original Software, to make, have made, use, practice, sell, and offer for sale, and/or otherwise dispose of the Original Software (or portions thereof). 509 | + 510 | 511 | (c) The licenses granted in Sections 2.1(a) and (b) are effective on the date Initial Developer first distributes or otherwise makes the Original Software available to a third party under the terms of this License. 512 | + 513 | 514 | (d) Notwithstanding Section 2.1(b) above, no patent license is granted: (1) for code that You delete from the Original Software, or (2) for infringements caused by: (i) the modification of the Original Software, or (ii) the combination of the Original Software with other software or devices. 515 | o 516 | 517 | 2.2. Contributor Grant. 518 | 519 | Conditioned upon Your compliance with Section 3.1 below and subject to third party intellectual property claims, each Contributor hereby grants You a world-wide, royalty-free, non-exclusive license: 520 | + 521 | 522 | (a) under intellectual property rights (other than patent or trademark) Licensable by Contributor to use, reproduce, modify, display, perform, sublicense and distribute the Modifications created by such Contributor (or portions thereof), either on an unmodified basis, with other Modifications, as Covered Software and/or as part of a Larger Work; and 523 | + 524 | 525 | (b) under Patent Claims infringed by the making, using, or selling of Modifications made by that Contributor either alone and/or in combination with its Contributor Version (or portions of such combination), to make, use, sell, offer for sale, have made, and/or otherwise dispose of: (1) Modifications made by that Contributor (or portions thereof); and (2) the combination of Modifications made by that Contributor with its Contributor Version (or portions of such combination). 526 | + 527 | 528 | (c) The licenses granted in Sections 2.2(a) and 2.2(b) are effective on the date Contributor first distributes or otherwise makes the Modifications available to a third party. 529 | + 530 | 531 | (d) Notwithstanding Section 2.2(b) above, no patent license is granted: (1) for any code that Contributor has deleted from the Contributor Version; (2) for infringements caused by: (i) third party modifications of Contributor Version, or (ii) the combination of Modifications made by that Contributor with other software (except as part of the Contributor Version) or other devices; or (3) under Patent Claims infringed by Covered Software in the absence of Modifications made by that Contributor. 532 | * 533 | 534 | 3. Distribution Obligations. 535 | o 536 | 537 | 3.1. Availability of Source Code. 538 | 539 | Any Covered Software that You distribute or otherwise make available in Executable form must also be made available in Source Code form and that Source Code form must be distributed only under the terms of this License. You must include a copy of this License with every copy of the Source Code form of the Covered Software You distribute or otherwise make available. You must inform recipients of any such Covered Software in Executable form as to how they can obtain such Covered Software in Source Code form in a reasonable manner on or through a medium customarily used for software exchange. 540 | o 541 | 542 | 3.2. Modifications. 543 | 544 | The Modifications that You create or to which You contribute are governed by the terms of this License. You represent that You believe Your Modifications are Your original creation(s) and/or You have sufficient rights to grant the rights conveyed by this License. 545 | o 546 | 547 | 3.3. Required Notices. 548 | 549 | You must include a notice in each of Your Modifications that identifies You as the Contributor of the Modification. You may not remove or alter any copyright, patent or trademark notices contained within the Covered Software, or any notices of licensing or any descriptive text giving attribution to any Contributor or the Initial Developer. 550 | o 551 | 552 | 3.4. Application of Additional Terms. 553 | 554 | You may not offer or impose any terms on any Covered Software in Source Code form that alters or restricts the applicable version of this License or the recipients’ rights hereunder. You may choose to offer, and to charge a fee for, warranty, support, indemnity or liability obligations to one or more recipients of Covered Software. However, you may do so only on Your own behalf, and not on behalf of the Initial Developer or any Contributor. You must make it absolutely clear that any such warranty, support, indemnity or liability obligation is offered by You alone, and You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of warranty, support, indemnity or liability terms You offer. 555 | o 556 | 557 | 3.5. Distribution of Executable Versions. 558 | 559 | You may distribute the Executable form of the Covered Software under the terms of this License or under the terms of a license of Your choice, which may contain terms different from this License, provided that You are in compliance with the terms of this License and that the license for the Executable form does not attempt to limit or alter the recipient’s rights in the Source Code form from the rights set forth in this License. If You distribute the Covered Software in Executable form under a different license, You must make it absolutely clear that any terms which differ from this License are offered by You alone, not by the Initial Developer or Contributor. You hereby agree to indemnify the Initial Developer and every Contributor for any liability incurred by the Initial Developer or such Contributor as a result of any such terms You offer. 560 | o 561 | 562 | 3.6. Larger Works. 563 | 564 | You may create a Larger Work by combining Covered Software with other code not governed by the terms of this License and distribute the Larger Work as a single product. In such a case, You must make sure the requirements of this License are fulfilled for the Covered Software. 565 | * 566 | 567 | 4. Versions of the License. 568 | o 569 | 570 | 4.1. New Versions. 571 | 572 | Sun Microsystems, Inc. is the initial license steward and may publish revised and/or new versions of this License from time to time. Each version will be given a distinguishing version number. Except as provided in Section 4.3, no one other than the license steward has the right to modify this License. 573 | o 574 | 575 | 4.2. Effect of New Versions. 576 | 577 | You may always continue to use, distribute or otherwise make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. If the Initial Developer includes a notice in the Original Software prohibiting it from being distributed or otherwise made available under any subsequent version of the License, You must distribute and make the Covered Software available under the terms of the version of the License under which You originally received the Covered Software. Otherwise, You may also choose to use, distribute or otherwise make the Covered Software available under the terms of any subsequent version of the License published by the license steward. 578 | o 579 | 580 | 4.3. Modified Versions. 581 | 582 | When You are an Initial Developer and You want to create a new license for Your Original Software, You may create and use a modified version of this License if You: (a) rename the license and remove any references to the name of the license steward (except to note that the license differs from this License); and (b) otherwise make it clear that the license contains terms which differ from this License. 583 | * 584 | 585 | 5. DISCLAIMER OF WARRANTY. 586 | 587 | COVERED SOFTWARE IS PROVIDED UNDER THIS LICENSE ON AN “AS IS” BASIS, WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, WITHOUT LIMITATION, WARRANTIES THAT THE COVERED SOFTWARE IS FREE OF DEFECTS, MERCHANTABLE, FIT FOR A PARTICULAR PURPOSE OR NON-INFRINGING. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE COVERED SOFTWARE IS WITH YOU. SHOULD ANY COVERED SOFTWARE PROVE DEFECTIVE IN ANY RESPECT, YOU (NOT THE INITIAL DEVELOPER OR ANY OTHER CONTRIBUTOR) ASSUME THE COST OF ANY NECESSARY SERVICING, REPAIR OR CORRECTION. THIS DISCLAIMER OF WARRANTY CONSTITUTES AN ESSENTIAL PART OF THIS LICENSE. NO USE OF ANY COVERED SOFTWARE IS AUTHORIZED HEREUNDER EXCEPT UNDER THIS DISCLAIMER. 588 | * 589 | 590 | 6. TERMINATION. 591 | o 592 | 593 | 6.1. This License and the rights granted hereunder will terminate automatically if You fail to comply with terms herein and fail to cure such breach within 30 days of becoming aware of the breach. Provisions which, by their nature, must remain in effect beyond the termination of this License shall survive. 594 | o 595 | 596 | 6.2. If You assert a patent infringement claim (excluding declaratory judgment actions) against Initial Developer or a Contributor (the Initial Developer or Contributor against whom You assert such claim is referred to as “Participant”) alleging that the Participant Software (meaning the Contributor Version where the Participant is a Contributor or the Original Software where the Participant is the Initial Developer) directly or indirectly infringes any patent, then any and all rights granted directly or indirectly to You by such Participant, the Initial Developer (if the Initial Developer is not the Participant) and all Contributors under Sections 2.1 and/or 2.2 of this License shall, upon 60 days notice from Participant terminate prospectively and automatically at the expiration of such 60 day notice period, unless if within such 60 day period You withdraw Your claim with respect to the Participant Software against such Participant either unilaterally or pursuant to a written agreement with Participant. 597 | o 598 | 599 | 6.3. In the event of termination under Sections 6.1 or 6.2 above, all end user licenses that have been validly granted by You or any distributor hereunder prior to termination (excluding licenses granted to You by any distributor) shall survive termination. 600 | * 601 | 602 | 7. LIMITATION OF LIABILITY. 603 | 604 | UNDER NO CIRCUMSTANCES AND UNDER NO LEGAL THEORY, WHETHER TORT (INCLUDING NEGLIGENCE), CONTRACT, OR OTHERWISE, SHALL YOU, THE INITIAL DEVELOPER, ANY OTHER CONTRIBUTOR, OR ANY DISTRIBUTOR OF COVERED SOFTWARE, OR ANY SUPPLIER OF ANY OF SUCH PARTIES, BE LIABLE TO ANY PERSON FOR ANY INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES OF ANY CHARACTER INCLUDING, WITHOUT LIMITATION, DAMAGES FOR LOST PROFITS, LOSS OF GOODWILL, WORK STOPPAGE, COMPUTER FAILURE OR MALFUNCTION, OR ANY AND ALL OTHER COMMERCIAL DAMAGES OR LOSSES, EVEN IF SUCH PARTY SHALL HAVE BEEN INFORMED OF THE POSSIBILITY OF SUCH DAMAGES. THIS LIMITATION OF LIABILITY SHALL NOT APPLY TO LIABILITY FOR DEATH OR PERSONAL INJURY RESULTING FROM SUCH PARTY’S NEGLIGENCE TO THE EXTENT APPLICABLE LAW PROHIBITS SUCH LIMITATION. SOME JURISDICTIONS DO NOT ALLOW THE EXCLUSION OR LIMITATION OF INCIDENTAL OR CONSEQUENTIAL DAMAGES, SO THIS EXCLUSION AND LIMITATION MAY NOT APPLY TO YOU. 605 | * 606 | 607 | 8. U.S. GOVERNMENT END USERS. 608 | 609 | The Covered Software is a “commercial item,” as that term is defined in 48 C.F.R. 2.101 (Oct. 1995), consisting of “commercial computer software” (as that term is defined at 48 C.F.R. § 252.227-7014(a)(1)) and “commercial computer software documentation” as such terms are used in 48 C.F.R. 12.212 (Sept. 1995). Consistent with 48 C.F.R. 12.212 and 48 C.F.R. 227.7202-1 through 227.7202-4 (June 1995), all U.S. Government End Users acquire Covered Software with only those rights set forth herein. This U.S. Government Rights clause is in lieu of, and supersedes, any other FAR, DFAR, or other clause or provision that addresses Government rights in computer software under this License. 610 | * 611 | 612 | 9. MISCELLANEOUS. 613 | 614 | This License represents the complete agreement concerning subject matter hereof. If any provision of this License is held to be unenforceable, such provision shall be reformed only to the extent necessary to make it enforceable. This License shall be governed by the law of the jurisdiction specified in a notice contained within the Original Software (except to the extent applicable law, if any, provides otherwise), excluding such jurisdiction’s conflict-of-law provisions. Any litigation relating to this License shall be subject to the jurisdiction of the courts located in the jurisdiction and venue specified in a notice contained within the Original Software, with the losing party responsible for costs, including, without limitation, court costs and reasonable attorneys’ fees and expenses. The application of the United Nations Convention on Contracts for the International Sale of Goods is expressly excluded. Any law or regulation which provides that the language of a contract shall be construed against the drafter shall not apply to this License. You agree that You alone are responsible for compliance with the United States export administration regulations (and the export control laws and regulation of any other countries) when You use, distribute or otherwise make available any Covered Software. 615 | * 616 | 617 | 10. RESPONSIBILITY FOR CLAIMS. 618 | 619 | As between Initial Developer and the Contributors, each party is responsible for claims and damages arising, directly or indirectly, out of its utilization of rights under this License and You agree to work with Initial Developer and Contributors to distribute such responsibility on an equitable basis. Nothing herein is intended or shall be deemed to constitute any admission of liability. 620 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | Embedded Apache ActiveMQ broker with STOMP over Websockets connector 2 | -------------------------------------------------------------------------------- /pom.xml: -------------------------------------------------------------------------------- 1 | 3 | 4.0.0 4 | 5 | com.example 6 | spring-activemq-stomp-websockets 7 | 0.0.1-SNAPSHOT 8 | jar 9 | 10 | 11 | UTF-8 12 | 3.2.2.RELEASE 13 | 14 | 15 | 16 | 17 | org.springframework 18 | spring-core 19 | ${org.springframework.version} 20 | 21 | 22 | 23 | org.springframework 24 | spring-context 25 | ${org.springframework.version} 26 | 27 | 28 | 29 | org.springframework 30 | spring-context-support 31 | ${org.springframework.version} 32 | 33 | 34 | 35 | org.springframework 36 | spring-jms 37 | ${org.springframework.version} 38 | 39 | 40 | 41 | ch.qos.logback 42 | logback-access 43 | 1.0.12 44 | 45 | 46 | 47 | ch.qos.logback 48 | logback-core 49 | 1.0.12 50 | 51 | 52 | 53 | ch.qos.logback 54 | logback-classic 55 | 1.0.12 56 | 57 | 58 | 59 | org.apache.activemq 60 | activemq-broker 61 | 5.8.0 62 | 63 | 64 | 65 | org.apache.activemq 66 | activemq-spring 67 | 5.8.0 68 | 69 | 70 | 71 | org.apache.activemq 72 | activemq-http 73 | 5.8.0 74 | 75 | 76 | 77 | org.apache.activemq 78 | activemq-stomp 79 | 5.8.0 80 | 81 | 82 | 83 | org.slf4j 84 | slf4j-api 85 | 1.7.5 86 | 87 | 88 | 89 | org.slf4j 90 | log4j-over-slf4j 91 | 1.7.5 92 | 93 | 94 | 95 | com.thoughtworks.xstream 96 | xstream 97 | 1.4.4 98 | 99 | 100 | 101 | junit 102 | junit 103 | 4.11 104 | test 105 | 106 | 107 | 108 | 109 | 110 | 111 | org.apache.maven.plugins 112 | maven-compiler-plugin 113 | 3.0 114 | 115 | 1.7 116 | 1.7 117 | 118 | 119 | 120 | 121 | 122 | -------------------------------------------------------------------------------- /src/main/java/com/example/messaging/AppConfig.java: -------------------------------------------------------------------------------- 1 | package com.example.messaging; 2 | 3 | import java.util.Collections; 4 | 5 | import org.apache.activemq.broker.BrokerService; 6 | import org.apache.activemq.broker.jmx.ManagementContext; 7 | import org.apache.activemq.command.ActiveMQDestination; 8 | import org.apache.activemq.command.ActiveMQTopic; 9 | import org.apache.activemq.hooks.SpringContextHook; 10 | import org.springframework.context.annotation.Bean; 11 | import org.springframework.context.annotation.Configuration; 12 | 13 | @Configuration 14 | public class AppConfig { 15 | @Bean( initMethod = "start", destroyMethod = "stop" ) 16 | public BrokerService broker() throws Exception { 17 | final BrokerService broker = new BrokerService(); 18 | broker.addConnector( "ws://localhost:61614" ); 19 | broker.setPersistent( false ); 20 | broker.setShutdownHooks( Collections.< Runnable >singletonList( new SpringContextHook() ) ); 21 | 22 | final ActiveMQTopic topic = new ActiveMQTopic( "jms.topic.test" ); 23 | broker.setDestinations( new ActiveMQDestination[] { topic } ); 24 | 25 | final ManagementContext managementContext = new ManagementContext(); 26 | managementContext.setCreateConnector( true ); 27 | broker.setManagementContext( managementContext ); 28 | 29 | return broker; 30 | } 31 | } 32 | -------------------------------------------------------------------------------- /src/main/java/com/example/messaging/Starter.java: -------------------------------------------------------------------------------- 1 | package com.example.messaging; 2 | 3 | import org.springframework.context.ApplicationContext; 4 | import org.springframework.context.annotation.AnnotationConfigApplicationContext; 5 | 6 | public class Starter { 7 | public static void main( String[] args ) { 8 | ApplicationContext context = new AnnotationConfigApplicationContext( AppConfig.class ); 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /src/main/javascript/index.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | -------------------------------------------------------------------------------- /src/main/javascript/stomp.js: -------------------------------------------------------------------------------- 1 | // Generated by CoffeeScript 1.4.0 2 | (function() { 3 | var Byte, Client, Frame, Stomp, 4 | __hasProp = {}.hasOwnProperty; 5 | 6 | Byte = { 7 | LF: '\x0A', 8 | NULL: '\x00' 9 | }; 10 | 11 | Frame = (function() { 12 | 13 | function Frame(command, headers, body) { 14 | this.command = command; 15 | this.headers = headers != null ? headers : {}; 16 | this.body = body != null ? body : ''; 17 | } 18 | 19 | Frame.prototype.toString = function() { 20 | var lines, name, value, _ref; 21 | lines = [this.command]; 22 | _ref = this.headers; 23 | for (name in _ref) { 24 | if (!__hasProp.call(_ref, name)) continue; 25 | value = _ref[name]; 26 | lines.push("" + name + ":" + value); 27 | } 28 | if (this.body) { 29 | lines.push("content-length:" + ('' + this.body).length); 30 | } 31 | lines.push(Byte.LF + this.body); 32 | return lines.join(Byte.LF); 33 | }; 34 | 35 | Frame._unmarshallSingle = function(data) { 36 | var body, chr, command, divider, headerLines, headers, i, idx, len, line, start, trim, _i, _j, _ref, _ref1; 37 | divider = data.search(RegExp("" + Byte.LF + Byte.LF)); 38 | headerLines = data.substring(0, divider).split(Byte.LF); 39 | command = headerLines.shift(); 40 | headers = {}; 41 | trim = function(str) { 42 | return str.replace(/^\s+|\s+$/g, ''); 43 | }; 44 | line = idx = null; 45 | for (i = _i = 0, _ref = headerLines.length; 0 <= _ref ? _i < _ref : _i > _ref; i = 0 <= _ref ? ++_i : --_i) { 46 | line = headerLines[i]; 47 | idx = line.indexOf(':'); 48 | headers[trim(line.substring(0, idx))] = trim(line.substring(idx + 1)); 49 | } 50 | body = ''; 51 | start = divider + 2; 52 | if (headers['content-length']) { 53 | len = parseInt(headers['content-length']); 54 | body = ('' + data).substring(start, start + len); 55 | } else { 56 | chr = null; 57 | for (i = _j = start, _ref1 = data.length; start <= _ref1 ? _j < _ref1 : _j > _ref1; i = start <= _ref1 ? ++_j : --_j) { 58 | chr = data.charAt(i); 59 | if (chr === Byte.NULL) { 60 | break; 61 | } 62 | body += chr; 63 | } 64 | } 65 | return new Frame(command, headers, body); 66 | }; 67 | 68 | Frame.unmarshall = function(datas) { 69 | var data; 70 | return (function() { 71 | var _i, _len, _ref, _results; 72 | _ref = datas.split(RegExp("" + Byte.NULL + Byte.LF + "*")); 73 | _results = []; 74 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 75 | data = _ref[_i]; 76 | if ((data != null ? data.length : void 0) > 0) { 77 | _results.push(Frame._unmarshallSingle(data)); 78 | } 79 | } 80 | return _results; 81 | })(); 82 | }; 83 | 84 | Frame.marshall = function(command, headers, body) { 85 | var frame; 86 | frame = new Frame(command, headers, body); 87 | return frame.toString() + Byte.NULL; 88 | }; 89 | 90 | return Frame; 91 | 92 | })(); 93 | 94 | Client = (function() { 95 | 96 | function Client(ws) { 97 | this.ws = ws; 98 | this.ws.binaryType = "arraybuffer"; 99 | this.counter = 0; 100 | this.connected = false; 101 | this.heartbeat = { 102 | outgoing: 10000, 103 | incoming: 10000 104 | }; 105 | this.subscriptions = {}; 106 | } 107 | 108 | Client.prototype._transmit = function(command, headers, body) { 109 | var out; 110 | out = Frame.marshall(command, headers, body); 111 | if (typeof this.debug === "function") { 112 | this.debug(">>> " + out); 113 | } 114 | return this.ws.send(out); 115 | }; 116 | 117 | Client.prototype._setupHeartbeat = function(headers) { 118 | var serverIncoming, serverOutgoing, ttl, v, _ref, _ref1, 119 | _this = this; 120 | if ((_ref = headers.version) !== Stomp.VERSIONS.V1_1 && _ref !== Stomp.VERSIONS.V1_2) { 121 | return; 122 | } 123 | _ref1 = (function() { 124 | var _i, _len, _ref1, _results; 125 | _ref1 = headers['heart-beat'].split(","); 126 | _results = []; 127 | for (_i = 0, _len = _ref1.length; _i < _len; _i++) { 128 | v = _ref1[_i]; 129 | _results.push(parseInt(v)); 130 | } 131 | return _results; 132 | })(), serverOutgoing = _ref1[0], serverIncoming = _ref1[1]; 133 | if (!(this.heartbeat.outgoing === 0 || serverIncoming === 0)) { 134 | ttl = Math.max(this.heartbeat.outgoing, serverIncoming); 135 | if (typeof this.debug === "function") { 136 | this.debug("send PING every " + ttl + "ms"); 137 | } 138 | this.pinger = typeof window !== "undefined" && window !== null ? window.setInterval(function() { 139 | _this.ws.send(Byte.LF); 140 | return typeof _this.debug === "function" ? _this.debug(">>> PING") : void 0; 141 | }, ttl) : void 0; 142 | } 143 | if (!(this.heartbeat.incoming === 0 || serverOutgoing === 0)) { 144 | ttl = Math.max(this.heartbeat.incoming, serverOutgoing); 145 | if (typeof this.debug === "function") { 146 | this.debug("check PONG every " + ttl + "ms"); 147 | } 148 | return this.ponger = typeof window !== "undefined" && window !== null ? window.setInterval(function() { 149 | var delta; 150 | delta = Date.now() - _this.serverActivity; 151 | if (delta > ttl * 2) { 152 | if (typeof _this.debug === "function") { 153 | _this.debug("did not receive server activity for the last " + delta + "ms"); 154 | } 155 | return _this.ws.close(); 156 | } 157 | }, ttl) : void 0; 158 | } 159 | }; 160 | 161 | Client.prototype.connect = function(login, passcode, connectCallback, errorCallback, vhost) { 162 | var _this = this; 163 | this.connectCallback = connectCallback; 164 | if (typeof this.debug === "function") { 165 | this.debug("Opening Web Socket..."); 166 | } 167 | this.ws.onmessage = function(evt) { 168 | var arr, c, data, frame, onreceive, _i, _len, _ref, _results; 169 | 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() { 170 | var _i, _len, _results; 171 | _results = []; 172 | for (_i = 0, _len = arr.length; _i < _len; _i++) { 173 | c = arr[_i]; 174 | _results.push(String.fromCharCode(c)); 175 | } 176 | return _results; 177 | })()).join('')) : evt.data; 178 | _this.serverActivity = Date.now(); 179 | if (data === Byte.LF) { 180 | if (typeof _this.debug === "function") { 181 | _this.debug("<<< PONG"); 182 | } 183 | return; 184 | } 185 | if (typeof _this.debug === "function") { 186 | _this.debug("<<< " + data); 187 | } 188 | _ref = Frame.unmarshall(data); 189 | _results = []; 190 | for (_i = 0, _len = _ref.length; _i < _len; _i++) { 191 | frame = _ref[_i]; 192 | switch (frame.command) { 193 | case "CONNECTED": 194 | if (typeof _this.debug === "function") { 195 | _this.debug("connected to server " + frame.headers.server); 196 | } 197 | _this.connected = true; 198 | _this._setupHeartbeat(frame.headers); 199 | _results.push(typeof _this.connectCallback === "function" ? _this.connectCallback(frame) : void 0); 200 | break; 201 | case "MESSAGE": 202 | onreceive = _this.subscriptions[frame.headers.subscription]; 203 | _results.push(typeof onreceive === "function" ? onreceive(frame) : void 0); 204 | break; 205 | case "RECEIPT": 206 | _results.push(typeof _this.onreceipt === "function" ? _this.onreceipt(frame) : void 0); 207 | break; 208 | case "ERROR": 209 | _results.push(typeof errorCallback === "function" ? errorCallback(frame) : void 0); 210 | break; 211 | default: 212 | _results.push(typeof _this.debug === "function" ? _this.debug("Unhandled frame: " + frame) : void 0); 213 | } 214 | } 215 | return _results; 216 | }; 217 | this.ws.onclose = function() { 218 | var msg; 219 | msg = "Whoops! Lost connection to " + _this.ws.url; 220 | if (typeof _this.debug === "function") { 221 | _this.debug(msg); 222 | } 223 | _this._cleanUp(); 224 | return typeof errorCallback === "function" ? errorCallback(msg) : void 0; 225 | }; 226 | return this.ws.onopen = function() { 227 | var headers; 228 | if (typeof _this.debug === "function") { 229 | _this.debug('Web Socket Opened...'); 230 | } 231 | headers = { 232 | "accept-version": Stomp.VERSIONS.supportedVersions(), 233 | "heart-beat": [_this.heartbeat.outgoing, _this.heartbeat.incoming].join(',') 234 | }; 235 | if (vhost) { 236 | headers.host = vhost; 237 | } 238 | if (login) { 239 | headers.login = login; 240 | } 241 | if (passcode) { 242 | headers.passcode = passcode; 243 | } 244 | return _this._transmit("CONNECT", headers); 245 | }; 246 | }; 247 | 248 | Client.prototype.disconnect = function(disconnectCallback) { 249 | this._transmit("DISCONNECT"); 250 | this.ws.onclose = null; 251 | this.ws.close(); 252 | this._cleanUp(); 253 | return typeof disconnectCallback === "function" ? disconnectCallback() : void 0; 254 | }; 255 | 256 | Client.prototype._cleanUp = function() { 257 | this.connected = false; 258 | if (this.pinger) { 259 | if (typeof window !== "undefined" && window !== null) { 260 | window.clearInterval(this.pinger); 261 | } 262 | } 263 | if (this.ponger) { 264 | return typeof window !== "undefined" && window !== null ? window.clearInterval(this.ponger) : void 0; 265 | } 266 | }; 267 | 268 | Client.prototype.send = function(destination, headers, body) { 269 | if (headers == null) { 270 | headers = {}; 271 | } 272 | if (body == null) { 273 | body = ''; 274 | } 275 | headers.destination = destination; 276 | return this._transmit("SEND", headers, body); 277 | }; 278 | 279 | Client.prototype.subscribe = function(destination, callback, headers) { 280 | if (headers == null) { 281 | headers = {}; 282 | } 283 | if (!headers.id) { 284 | headers.id = "sub-" + this.counter++; 285 | } 286 | headers.destination = destination; 287 | this.subscriptions[headers.id] = callback; 288 | this._transmit("SUBSCRIBE", headers); 289 | return headers.id; 290 | }; 291 | 292 | Client.prototype.unsubscribe = function(id) { 293 | delete this.subscriptions[id]; 294 | return this._transmit("UNSUBSCRIBE", { 295 | id: id 296 | }); 297 | }; 298 | 299 | Client.prototype.begin = function(transaction) { 300 | return this._transmit("BEGIN", { 301 | transaction: transaction 302 | }); 303 | }; 304 | 305 | Client.prototype.commit = function(transaction) { 306 | return this._transmit("COMMIT", { 307 | transaction: transaction 308 | }); 309 | }; 310 | 311 | Client.prototype.abort = function(transaction) { 312 | return this._transmit("ABORT", { 313 | transaction: transaction 314 | }); 315 | }; 316 | 317 | Client.prototype.ack = function(messageID, subscription, headers) { 318 | if (headers == null) { 319 | headers = {}; 320 | } 321 | headers["message-id"] = messageID; 322 | headers.subscription = subscription; 323 | return this._transmit("ACK", headers); 324 | }; 325 | 326 | Client.prototype.nack = function(messageID, subscription, headers) { 327 | if (headers == null) { 328 | headers = {}; 329 | } 330 | headers["message-id"] = messageID; 331 | headers.subscription = subscription; 332 | return this._transmit("NACK", headers); 333 | }; 334 | 335 | return Client; 336 | 337 | })(); 338 | 339 | Stomp = { 340 | libVersion: "2.0.0-next", 341 | VERSIONS: { 342 | V1_0: '1.0', 343 | V1_1: '1.1', 344 | V1_2: '1.2', 345 | supportedVersions: function() { 346 | return '1.1,1.0'; 347 | } 348 | }, 349 | client: function(url, protocols) { 350 | var klass, ws; 351 | if (protocols == null) { 352 | protocols = ['v10.stomp', 'v11.stomp']; 353 | } 354 | klass = Stomp.WebSocketClass || WebSocket; 355 | ws = new klass(url, protocols); 356 | return new Client(ws); 357 | }, 358 | over: function(ws) { 359 | return new Client(ws); 360 | }, 361 | Frame: Frame 362 | }; 363 | 364 | if (typeof window !== "undefined" && window !== null) { 365 | window.Stomp = Stomp; 366 | } else if (typeof exports !== "undefined" && exports !== null) { 367 | exports.Stomp = Stomp; 368 | Stomp.WebSocketClass = require('./test/server.mock.js').StompServerMock; 369 | } else { 370 | self.Stomp = Stomp; 371 | } 372 | 373 | }).call(this); 374 | --------------------------------------------------------------------------------