├── .codeclimate.yml
├── .eslintrc
├── .gitignore
├── .jshintrc
├── .travis.yml
├── CHANGELOG.md
├── LICENSE
├── README.md
├── bower.json
├── build
├── paths.js
└── tasks
│ ├── build.js
│ ├── coveralls.js
│ ├── lint.js
│ └── release.js
├── config.js
├── core
├── builder.js
├── builder.spec.js
├── ngStomp.js
├── ngStomp.spec.js
├── provider.js
├── provider.spec.js
├── service.js
├── service.spec.js
├── unSubscriber.js
└── unSubscriber.spec.js
├── dist
├── angular-stomp.js
├── angular-stomp.min.js
└── angular-stomp.min.js.map
├── gulpfile.babel.js
├── index.js
├── karma.conf.js
├── mock
└── ngStomp.js
└── package.json
/.codeclimate.yml:
--------------------------------------------------------------------------------
1 | engines:
2 | eslint:
3 | enabled: true
4 |
5 | ratings:
6 | paths:
7 | - "core/**"
8 |
9 | exclude_paths:
10 | - "core/**/*.spec.js"
11 | - "dist/*"
12 | - "build/**/*"
13 | - "mock/**/*.js"
14 | - "*.js"
15 | - "*.json"
16 | - "*.md"
17 | - "LICENSE"
18 |
--------------------------------------------------------------------------------
/.eslintrc:
--------------------------------------------------------------------------------
1 | {
2 | "parser": "babel-eslint",
3 | "rules": {
4 | "linebreak-style": [ 2, "unix" ],
5 | "semi": [ 2, "always" ]
6 | },
7 | "env": {
8 | "es6": true,
9 | "browser": true,
10 | "jasmine": true
11 | },
12 | "globals": {
13 | "inject": true,
14 | "module": true
15 | },
16 | "extends": "eslint:recommended",
17 | "ecmaFeatures": {
18 | "modules" : true
19 | }
20 | }
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /jspm_packages/
2 | .idea
3 | *.iml
4 | node*/
5 | /reports
6 | coverage
--------------------------------------------------------------------------------
/.jshintrc:
--------------------------------------------------------------------------------
1 | {
2 | "esnext": true,
3 | "expr" : true,
4 | "globals": {
5 | "angular" : false,
6 | "_" : false
7 | }
8 | }
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: node_js
2 | node_js:
3 | - "0.12"
4 |
5 | install:
6 | - npm install --quiet -g gulp karma jspm
7 |
8 | before_script:
9 | - npm install
10 | - jspm config registries.github.auth $JSPM_GITHUB_AUTH_TOKEN
11 |
12 | script: npm test
13 |
14 | after_success:
15 | - gulp coveralls
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 |
2 | # [0.11.0](https://github.com/davinkevin/AngularStompDK/compare/v0.10.0...v0.11.0) (2016-12-04)
3 |
4 |
5 | ### Features
6 |
7 | * **connection:** support header during connection ([3484a8c](https://github.com/davinkevin/AngularStompDK/commit/3484a8c)), closes [#47](https://github.com/davinkevin/AngularStompDK/issues/47)
8 |
9 |
10 |
11 |
12 | # [0.10.0](https://github.com/davinkevin/AngularStompDK/compare/v0.9.3...v0.10.0) (2016-08-29)
13 |
14 |
15 | ### Features
16 |
17 | * **config:** being able to configure the credentials / url after angular#config phase ([44692c0](https://github.com/davinkevin/AngularStompDK/commit/44692c0)), closes [#44](https://github.com/davinkevin/AngularStompDK/issues/44)
18 |
19 |
20 |
21 |
22 | ## [0.9.3](https://github.com/davinkevin/AngularStompDK/compare/v0.9.2...v0.9.3) (2016-07-04)
23 |
24 |
25 | ### Features
26 |
27 | * **connectionState:** The state of the connection can be accessed by the promise on the ngStomp servic ([7d0e74e](https://github.com/davinkevin/AngularStompDK/commit/7d0e74e))
28 |
29 |
30 |
31 |
32 | ## [0.9.2](https://github.com/davinkevin/AngularStompDK/compare/v0.9.1...v0.9.2) (2016-06-28)
33 |
34 |
35 | ### Bug Fixes
36 |
37 | * **subscription:** add missing digest parameter ([a0dcb8a](https://github.com/davinkevin/AngularStompDK/commit/a0dcb8a))
38 |
39 |
40 |
41 |
42 | ## [0.9.1](https://github.com/davinkevin/AngularStompDK/compare/v0.9.0...v0.9.1) (2016-06-27)
43 |
44 |
45 | ### Bug Fixes
46 |
47 | * **builder:** define $scope to undefined to fallback on $rootScope ([967d919](https://github.com/davinkevin/AngularStompDK/commit/967d919)), closes [#39](https://github.com/davinkevin/AngularStompDK/issues/39)
48 |
49 |
50 |
51 |
52 | # [0.9.0](https://github.com/davinkevin/AngularStompDK/compare/v0.8.6...v0.9.0) (2016-06-27)
53 |
54 |
55 | ### Features
56 |
57 | * **$digest:** possibility to disable automatic digest cycle after a reception of data ([dbec917](https://github.com/davinkevin/AngularStompDK/commit/dbec917)), closes [#36](https://github.com/davinkevin/AngularStompDK/issues/36)
58 |
59 |
60 |
61 |
62 | ## [0.8.6](https://github.com/davinkevin/AngularStompDK/compare/v0.8.5...v0.8.6) (2016-06-25)
63 |
64 |
65 | ### Bug Fixes
66 |
67 | * **subscription:** Lost subscriptions when first connection attempt failed ([a9037df](https://github.com/davinkevin/AngularStompDK/commit/a9037df)), closes [#38](https://github.com/davinkevin/AngularStompDK/issues/38)
68 |
69 | ### Performance Improvements
70 |
71 | * **$digest:** reduce digest cycle and remove call to private method of angular ([3dc3541](https://github.com/davinkevin/AngularStompDK/commit/3dc3541))
72 |
73 |
74 |
75 |
76 | ## [0.8.5](https://github.com/davinkevin/AngularStompDK/compare/v0.8.4...v0.8.5) (2016-06-19)
77 |
78 |
79 | ### Bug Fixes
80 |
81 | * **unSubscriber:** correction on queue unSubscription ([2194a86](https://github.com/davinkevin/AngularStompDK/commit/2194a86))
82 |
83 |
84 |
85 |
86 | ## [0.8.4](https://github.com/davinkevin/AngularStompDK/compare/v0.8.2...v0.8.4) (2016-06-18)
87 |
88 |
89 | ### Features
90 |
91 | * **reconnection:** disable auto re-connection system if a tiemOut value is less than 0 ([cde3089](https://github.com/davinkevin/AngularStompDK/commit/cde3089))
92 |
93 |
94 |
95 |
96 | ## [0.8.2](https://github.com/davinkevin/AngularStompDK/compare/v0.8.1...v0.8.2) (2016-03-03)
97 |
98 |
99 | ### Bug Fixes
100 |
101 | * **reconnect:** fix doubling connections after reconnect ([dda7542](https://github.com/davinkevin/AngularStompDK/commit/dda7542))
102 |
103 |
104 |
105 |
106 | ## [0.8.1](https://github.com/davinkevin/AngularStompDK/compare/v0.8.0...v0.8.1) (2016-02-21)
107 |
108 |
109 | ### Bug Fixes
110 |
111 | * **codeclimate:** fix some issue ([15e5292](https://github.com/davinkevin/AngularStompDK/commit/15e5292))
112 | * **injection:** change injection of ngAnnotate and not minified with annotation ([12de8c9](https://github.com/davinkevin/AngularStompDK/commit/12de8c9))
113 |
114 |
115 |
116 |
117 | # [0.8.0](https://github.com/davinkevin/AngularStompDK/compare/v0.7.0...v0.8.0) (2016-01-14)
118 |
119 |
120 | ### Bug Fixes
121 |
122 | * **unSubscribe:** don't remove connections if unRegistration from position ([1278bbe](https://github.com/davinkevin/AngularStompDK/commit/1278bbe))
123 | * **unSubscribe:** remove connection based on index attribute to prevent mis-organisation in the ar ([1b04d67](https://github.com/davinkevin/AngularStompDK/commit/1b04d67))
124 | * **unsubscriber:** change case of import ([c63a8d4](https://github.com/davinkevin/AngularStompDK/commit/c63a8d4))
125 |
126 | ### Features
127 |
128 | * **unsubscriber:** allow to unsubscribe each subscription individually ([ca6115f](https://github.com/davinkevin/AngularStompDK/commit/ca6115f))
129 |
130 | ### Performance Improvements
131 |
132 | * **service:** remove usage of set because two subscription can append to the same topic ([9898775](https://github.com/davinkevin/AngularStompDK/commit/9898775))
133 |
134 |
135 |
136 |
137 | # [0.7.0](https://github.com/davinkevin/AngularStompDK/compare/v0.6.2...v0.7.0) (2016-01-09)
138 |
139 |
140 | ### Features
141 |
142 | * **license:** add Apache License ([907e4c8](https://github.com/davinkevin/AngularStompDK/commit/907e4c8))
143 | * **readme:** add better description and let only the builder pattern to subscribe ([4e9730d](https://github.com/davinkevin/AngularStompDK/commit/4e9730d))
144 | * **service:** support auto-conversion in JSON of message body ([ed543f2](https://github.com/davinkevin/AngularStompDK/commit/ed543f2))
145 |
146 |
147 |
148 |
149 | ## [0.6.2](https://github.com/davinkevin/AngularStompDK/compare/v0.6.1...v0.6.2) (2016-01-03)
150 |
151 |
152 | ### Features
153 |
154 | * **bower:** add bower.json file to brought back bower support (sorry for that...) ([df533a5](https://github.com/davinkevin/AngularStompDK/commit/df533a5))
155 |
156 |
157 |
158 |
159 | ## [0.6.2](https://github.com/davinkevin/AngularStompDK/compare/v0.6.1...v0.6.2) (2016-01-03)
160 |
161 |
162 | ### Features
163 |
164 | * **bower:** add bower.json file to brought back bower support (sorry for that...) ([df533a5](https://github.com/davinkevin/AngularStompDK/commit/df533a5))
165 |
166 |
167 |
168 |
169 | ## [0.6.1](https://github.com/davinkevin/AngularStompDK/compare/v0.6.0...v0.6.1) (2016-01-02)
170 |
171 |
172 | ### Features
173 |
174 | * **re-connection:** allow configuration to trigger re-connection every X seconds ([6ce93b0](https://github.com/davinkevin/AngularStompDK/commit/6ce93b0))
175 |
176 |
177 |
178 |
179 | # [0.6.0](https://github.com/davinkevin/AngularStompDK/compare/v0.5.2...v0.6.0) (2016-01-01)
180 |
181 |
182 | ### Features
183 |
184 | * **re-connection:** automatically reconnect if connection lost ([06efc8e](https://github.com/davinkevin/AngularStompDK/commit/06efc8e)), closes [#13](https://github.com/davinkevin/AngularStompDK/issues/13)
185 |
186 |
187 |
188 |
189 | ## [0.5.2](https://github.com/davinkevin/AngularStompDK/compare/v0.5.1...v0.5.2) (2016-01-01)
190 |
191 |
192 | ### Bug Fixes
193 |
194 | * **build:** change name of global value for es5 build ([70f0625](https://github.com/davinkevin/AngularStompDK/commit/70f0625))
195 |
196 |
197 |
198 |
199 | ## [0.5.1](https://github.com/davinkevin/AngularStompDK/compare/v0.5.0...v0.5.1) (2015-12-31)
200 |
201 |
202 | ### Bug Fixes
203 |
204 | * **build:** change variable of folder name ([a0fc905](https://github.com/davinkevin/AngularStompDK/commit/a0fc905))
205 |
206 |
207 |
208 |
209 | # [0.5.0](https://github.com/davinkevin/AngularStompDK/compare/v0.4.1...v0.5.0) (2015-12-31)
210 |
211 |
212 | ### Features
213 |
214 | * **changelog:** add changelog to master ([13bb344](https://github.com/davinkevin/AngularStompDK/commit/13bb344))
215 | * **readme:** update location of file in es6 configuraiton ([df51c4e](https://github.com/davinkevin/AngularStompDK/commit/df51c4e))
216 |
217 |
218 |
219 |
220 | # [0.4.0](https://github.com/davinkevin/AngularStompDK/compare/v0.3.4...v0.4.0) (2015-12-27)
221 |
222 |
223 | ### Bug Fixes
224 |
225 | * **package.json:** fix syntax in file ([c5a002f](https://github.com/davinkevin/AngularStompDK/commit/c5a002f))
226 |
227 |
228 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
178 | APPENDIX: How to apply the Apache License to your work.
179 |
180 | To apply the Apache License to your work, attach the following
181 | boilerplate notice, with the fields enclosed by brackets "{}"
182 | replaced with your own identifying information. (Don't include
183 | the brackets!) The text should be enclosed in the appropriate
184 | comment syntax for the file format. We also recommend that a
185 | file or class name and description of purpose be included on the
186 | same "printed page" as the copyright notice for easier
187 | identification within third-party archives.
188 |
189 | Copyright {yyyy} {name of copyright owner}
190 |
191 | Licensed under the Apache License, Version 2.0 (the "License");
192 | you may not use this file except in compliance with the License.
193 | You may obtain a copy of the License at
194 |
195 | http://www.apache.org/licenses/LICENSE-2.0
196 |
197 | Unless required by applicable law or agreed to in writing, software
198 | distributed under the License is distributed on an "AS IS" BASIS,
199 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
200 | See the License for the specific language governing permissions and
201 | limitations under the License.
202 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | AngularStompDK
2 | ============
3 |
4 | [](https://gitter.im/davinkevin/AngularStompDK?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
5 |
6 | [](https://badge.fury.io/js/AngularStompDK) [](https://badge.fury.io/bo/AngularStompDK)
7 |
8 | [](https://travis-ci.org/davinkevin/AngularStompDK) [](https://coveralls.io/r/davinkevin/AngularStompDK?branch=master) [](https://codeclimate.com/github/davinkevin/AngularStompDK)
9 |
10 | Angular service to Stomp Websocket Library.
11 | This library is an interface between native Stomp comunication and AngularJS
12 | This service relies on stomp.js that can be found at: https://github.com/jmesnil/stomp-websocket/
13 |
14 | ### 1. Installation
15 | ----------------
16 |
17 | This library is developped in ES2015 (and with some ES20XX features) and transpilled into plain old Javascript for browser compatibility. You can choose to use this lib from a standard AngularJS Project or inside a AngularJS written in ES2015.
18 |
19 | #### 1. 1. ES5 : Plain Old Javascript
20 |
21 | You have to import the transpiled files (normaly located in the dist folder) in your Single Page App.
22 | Don't forget to import Angular and Stomp.js first (because the lib relies on it).
23 |
24 | ```html
25 |
26 |
27 |
28 | ```
29 |
30 | And add the dependency to your Angular application :
31 |
32 | ```js
33 | angular.module('myApp', [ 'AngularStompDK' ])
34 | ```
35 | #### 1. 2. NPM
36 | You can install this package with the standard node package manager, with a simple `npm install AngularStompDK`
37 |
38 | #### 1. 3. ES2015 and more
39 | ----------------
40 | You can now (since version 0.4.0) import AngularStompDK directly from [JSPM](http://jspm.io/) (Package manager build upon SystemJS)
41 |
42 | ```
43 | $ jspm install github:AngularStompDK
44 | ```
45 |
46 | All the dependencies will automatically be fetch (kind of magic, isn't it :D) and you just have to register the lib at the AngularJS level (described here with the bootstrap method, commonly used in JSPM | ES2015 environnement).
47 |
48 | ```js
49 | import angular from 'angular';
50 | import 'AngularStompDK'; // <-- Loading the full transpiled file from dist
51 | ...
52 |
53 | let app = angular.module('MyWonderfullStompApp', [ 'AngularStompDK' ] );
54 |
55 | angular
56 | .element(document)
57 | .ready(() => angular.bootstrap(element, [ app ] ));
58 | ```
59 |
60 | You also can load the ES2015 file and use your current transpiler to use AngularStompDK. For this, we have to use the relative path of the entrypoint in the project
61 |
62 | ```js
63 | import angular from 'angular';
64 | import ngStomp from 'AngularStompDK/core/ngStomp'; // Path to the main ES6 Module
65 | ...
66 |
67 | let app = angular.module('MyWonderfullStompApp', [ ngStomp.name ] );
68 |
69 | ...
70 | ```
71 |
72 |
73 | #### 2. Configuration
74 | ----------------
75 |
76 | All the code example will be written in ES5 for the moment, if some of you would like to have example in ES2015, open an issue or do a PR.
77 |
78 | ##### 2. 1. Standard configuration
79 | ----------------
80 |
81 | Configure the ngStomp module to connect to your web-socket system :
82 |
83 | ```js
84 | angular.module('myApp')
85 | .config(function(ngstompProvider){
86 | ngstompProvider
87 | .url('/ws')
88 | .credential('login', 'password')
89 | });
90 | ```
91 |
92 | ##### 2. 2. Configuration with underlying implementation
93 | ----------------
94 |
95 | If you want to use a sub-system to do the connection, like SockJS, you can add the class name in the configuration part.
96 | Don't forget to import this underlying library in your page via Bower (and HTML script tag or other) or via JSPM.
97 |
98 | ```js
99 | angular.module('myApp')
100 | .config(function(ngstompProvider){
101 | ngstompProvider
102 | .url('/ws')
103 | .credential('login', 'password')
104 | .class(SockJS); // <-- Will be used by StompJS to do the connection
105 | });
106 | ```
107 |
108 | #### 3. 1. Receive information from Stomp Web-Socket
109 | ----------------
110 |
111 | Use it inside your controller (or everywhere you want !)
112 |
113 | ```js
114 | angular.controller('myController', function($scope, ngstomp) {
115 |
116 | var items = [];
117 |
118 | ngstomp
119 | .subscribeTo('/topic/item')
120 | .callback(whatToDoWhenMessageComming)
121 | .connect()
122 |
123 | function whatToDoWhenMessageComming(message) {
124 | items.push(JSON.parse(message.body));
125 | }
126 | });
127 | ```
128 |
129 | You can chain multiple subscribe and add headers to your subscription :
130 |
131 | ```js
132 | angular.controller('myController', function($scope, ngstomp) {
133 | var vm = this, headers = {
134 | foo : 'bar'
135 | };
136 | vm.items = [];
137 |
138 |
139 | ngstomp
140 | .subscribeTo('/topic/item1')
141 | .callback(whatToDoWhenMessageComming)
142 | .and()
143 | .subscribeTo('/topic/item2')
144 | .callback(whatToDoWhenMessageComming)
145 | .withHeaders(headers)
146 | .connect();
147 |
148 | function whatToDoWhenMessageComming(message) {
149 | vm.items.push(JSON.parse(message.body));
150 | }
151 | });
152 | ```
153 |
154 | If the body has to be in JSON, let the library handle the transformation of `message.body`
155 |
156 | ```js
157 | angular.controller('myController', function($scope, ngstomp) {
158 |
159 | var items = [];
160 |
161 | ngstomp
162 | .subscribeTo('/topic/item')
163 | .callback(whatToDoWhenMessageComming)
164 | .withBodyInJson()
165 | .connect();
166 |
167 | function whatToDoWhenMessageComming(message) {
168 | items.push(message.body);
169 | }
170 | });
171 | ```
172 |
173 | **Since 0.9.0** : You also can disable the digest cycle to be performed after each reception (enabled by default)
174 |
175 | ```js
176 | angular.controller('myController', function($scope, ngstomp) {
177 |
178 | var items = [];
179 |
180 | ngstomp
181 | .subscribeTo('/topic/item')
182 | .callback(whatToDoWhenMessageComming)
183 | .withBodyInJson()
184 | .withDigest(false)
185 | .connect();
186 |
187 | function whatToDoWhenMessageComming(message) {
188 | items.push(message.body);
189 | }
190 | });
191 | ```
192 |
193 | Give to the builder the $scope to allow the system to un-register the connection after the $scope destruction :
194 |
195 | ```js
196 | angular.controller('myController', function($scope, ngstomp) {
197 |
198 | var items = [];
199 |
200 | ngstomp
201 | .subscribeTo('/topic/item')
202 | .callback(whatToDoWhenMessageComming)
203 | .withBodyInJson()
204 | .bindTo($scope)
205 | .connect();
206 |
207 | function whatToDoWhenMessageComming(message) {
208 | items.push(message.body);
209 | }
210 | });
211 | ```
212 |
213 | Or, in an angular component environment, use the $onDestroy hook to un-register the connection, and thanks to this, you should not need to use the old and ugly $scope :
214 |
215 | ```js
216 | angular.component('myComp', {
217 | bindings : {},
218 | controller : function(ngstomp) {
219 |
220 | this.$onInit = function() {
221 | this.items = [];
222 |
223 | this.unSubscriber = ngstomp
224 | .subscribeTo('/topic/item')
225 | .callback(whatToDoWhenMessageComming)
226 | .withBodyInJson()
227 | .bindTo($scope)
228 | .connect();
229 | };
230 |
231 | this.$onDestroy = function() {
232 | this.unSubscriber.unSubscribeAll();
233 | }
234 |
235 | this.whatToDoWhenMessageComming = function(message) {
236 | items.push(message.body);
237 | }
238 | }
239 | });
240 | ```
241 |
242 | #### 3. 2. Send information
243 | ----------------
244 |
245 | You can send back information to the Web-Socket :
246 |
247 | ```js
248 | angular.controller('myController', function($scope, ngstomp) {
249 |
250 | var items = [];
251 |
252 | ngstomp
253 | .subscribeTo('/topic/item')
254 | .callback(whatToDoWhenMessageComming)
255 | .bindTo($scope)
256 | .connect();
257 |
258 | function whatToDoWhenMessageComming(message) {
259 | items.push(JSON.parse(message.body));
260 | }
261 |
262 | var objectToSend = { message : 'Hello Web-Socket'},
263 | stompHeaders = {headers1 : 'xx', headers2 : 'yy'};
264 |
265 | this.sendDataToWS = function(message) {
266 | ngstomp
267 | .send('/topic/item/message', objectToSend, stompHeaders);
268 | }
269 | });
270 | ```
271 |
272 | When you send data, the system return a promise (like in standard rest communication :D), so you can chain multiple synchronous communication :
273 |
274 | ```js
275 | angular.controller('myController', function($scope, ngstomp) {
276 |
277 | var items = [];
278 |
279 | ngstomp
280 | .subscribeTo('/topic/item')
281 | .callback(whatToDoWhenMessageComming)
282 | .bindTo($scope)
283 | .connect();
284 |
285 | function whatToDoWhenMessageComming(message) {
286 | items.push(JSON.parse(message.body));
287 | }
288 |
289 | var objectToSend = { message : 'Hello Web-Socket'},
290 | stompHeaders = {headers1 : 'xx', headers2 : 'yy'};
291 |
292 | this.sendDataToWS = function(message) {
293 | ngstomp
294 | .send('/topic/item/message1', objectToSend, stompHeaders)
295 | .then(function() { return ngstom.send('/topic/item/message2', objectToSend, stompHeaders) });
296 | .then(function() { return ngstom.send('/topic/item/message3', objectToSend, stompHeaders) });
297 | }
298 | });
299 | ```
300 |
301 | #### 3. 3. UnSubscribe from topic
302 | ----------------
303 |
304 | The `connect()` function return an object commonly called an unSubscriber. It handles all the logic of unSubscribing from a Stomp topic.
305 | You can, for example, unSubscribed from all the subject at once with the function `unSubscribeAll()`:
306 |
307 | ```js
308 | angular.controller('myController', function(ngstomp) {
309 | var vm = this;
310 |
311 | var unSubscriber = ngstomp
312 | .subscribeTo('/topic/item1')
313 | .callback(receiveFromTopic1)
314 | .and()
315 | .subscribeTo('/topic/item2')
316 | .callback(receiveFromTopic2)
317 | .connect();
318 |
319 | function receiveFromTopic1(m) { vm.items.push(JSON.parse(m.body)); }
320 | function receiveFromTopic2(m) { vm.items.push(JSON.parse(m.body)); }
321 |
322 | vm.unSubscribeAll = function() {
323 | unSubscriber.unSubscribeAll();
324 | }
325 | });
326 | ```
327 |
328 | Or you can choose to unSubscribed a subject by its topic url with the function `unSubscribeOf(TOPIC_URL)`:
329 |
330 | ```js
331 | angular.controller('myController', function(ngstomp) {
332 | var vm = this;
333 |
334 | var unSubscriber = ngstomp
335 | .subscribeTo('/topic/item1')
336 | .callback(receiveFromTopic1)
337 | .and()
338 | .subscribeTo('/topic/item2')
339 | .callback(receiveFromTopic2)
340 | .connect();
341 |
342 |
343 | function receiveFromTopic1(m) { vm.items.push(JSON.parse(m.body)); }
344 | function receiveFromTopic2(m) { vm.items.push(JSON.parse(m.body)); }
345 |
346 | vm.unSubOfTopic1 = function() {
347 | unSubscriber.unSubscribeOf('/topic/item1');
348 | }
349 |
350 | vm.unSubOfTopic2 = function() {
351 | unSubscriber.unSubscribeOf('/topic/item2');
352 | }
353 | });
354 | ```
355 |
356 | Because you can register the same topic with different parameters (callback, headers...), the function `unSubscribeOf(TOPIC_URL)` will unsubscribe from any topic with the same url, so it coul lead to multiple unsubscribe.
357 | If you want to unsubscribe from 1 topic specificaly, you have two solution :
358 |
359 | First one, without doing chaining in subscription :
360 |
361 | ```js
362 | angular.controller('myController', function(ngstomp) {
363 | var vm = this;
364 |
365 | var unSubscriberFirst = ngstomp
366 | .subscribeTo('/topic/item1')
367 | .callback(receiveFromTopic1)
368 | .connect();
369 |
370 | var unSubscriberSecond = ngstomp
371 | .subscribeTo('/topic/item1')
372 | .callback(receiveFromTopic1WithDifferentAction)
373 | .withHeaders({foo : 'bar'})
374 | .connect();
375 |
376 |
377 | function receiveFromTopic1(m) { vm.items.push(JSON.parse(m.body)); }
378 | function receiveFromTopic1WithDifferentAction(m) { console.log(JSON.parse(m.body)); }
379 |
380 | vm.unSubOfFirst = function() {
381 | unSubscriberFirst.unSubscribeAll();
382 | }
383 |
384 | vm.unSubOfSecond = function() {
385 | unSubscriberSecond.unSubscribeAll();
386 | }
387 | });
388 | ```
389 |
390 | The previous version is too verbose and lead to multiple var declaration. You can use the function `unSubscribeNth(Nth_Subscription)` on the unSubscriber.
391 | The nth position is '0 based', so the first is 0 (like in an array :D).
392 |
393 |
394 | ```js
395 | angular.controller('myController', function(ngstomp) {
396 | var vm = this;
397 |
398 | var unSubscriberFirst = ngstomp
399 | .subscribeTo('/topic/item1')
400 | .callback(receiveFromTopic1)
401 | .and()
402 | .subscribeTo('/topic/item1')
403 | .callback(receiveFromTopic1WithDifferentAction)
404 | .withHeaders({foo : 'bar'})
405 | .connect();
406 |
407 |
408 | function receiveFromTopic1(m) { vm.items.push(JSON.parse(m.body)); }
409 | function receiveFromTopic1WithDifferentAction(m) { console.log(JSON.parse(m.body)); }
410 |
411 | vm.unSubOfFirst = function() {
412 | unSubscriberFirst.unSubscribeNth(1);
413 | }
414 |
415 | vm.unSubOfSecond = function() {
416 | unSubscriberSecond.unSubscribeNth(2);
417 | }
418 | });
419 | ```
420 |
421 | ## Frequently Asked Question :
422 |
423 | ##### Why using $scope ? This seems to be deprecated in angularJs version since 1.3 ?
424 | The $scope is the only bridge between Angular Lifecycle and standard HTML behaviour (like web-socket). To keep both in sync, we have to use the $scope.
425 |
426 | ##### How can I contribute to this project ? Because I think a very important feature is missing...
427 | This project is totally open-source, and I'll be glad to see Push Request, so Fork it, improve it, test it (don't forget !) and do PR. It's very simple to work that way.
428 |
429 | ##### I have some question and I don't understand how it works, what can I do ?
430 | First of all, I encourage you to read the implementation of the lib, and even the tests. Right now, it's only 200 lines of code (without the test), so it's very simple (read the ES2015 version, not the transpilled version...).
431 | If it doesn't help, feel free to open a issue on the github, and if I can help, I will try to.
432 |
433 | ##### I have another question and it's not in this FAQ
434 | Like the previous question, open an issue and I will add it to this README (or you can do a PR only on this file).
435 |
436 |
--------------------------------------------------------------------------------
/bower.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "AngularStompDK",
3 | "version": "0.11.0",
4 | "main": "dist/angular-stomp.js",
5 | "ignore": [
6 | "build",
7 | "core",
8 | ".bowerrc",
9 | ".codeclimate.yml",
10 | ".eslintrc",
11 | ".gitignore",
12 | ".jshitrc",
13 | ".travis.yml",
14 | "bower.json",
15 | "CHANGELOG.md",
16 | "config.js",
17 | "gulpfile.babel.js",
18 | "karma.conf.js",
19 | "package.json",
20 | "README.md"
21 | ],
22 | "dependencies": {
23 | "angular": ">=1.2.0",
24 | "stomp-websocket": "~2.3.0"
25 | },
26 | "devDependencies": {
27 | "angular-mocks": ">=1.2.0"
28 | }
29 | }
--------------------------------------------------------------------------------
/build/paths.js:
--------------------------------------------------------------------------------
1 |
2 | import path from 'path';
3 |
4 | /* All constant and location of the application */
5 | const appName = 'angular-stomp';
6 | const srcDirName = 'core';
7 | const releaseDirName = 'dist';
8 | const root = path.dirname(__dirname);
9 |
10 | export default {
11 | root : root,
12 | systemConfigJs : `${srcDirName}/config.js`,
13 | packageJson : `${root}/package.json`,
14 | bowerJson : `${root}/bower.json`,
15 | changeLog : `${root}/CHANGELOG.md`,
16 | srcDir: `${root}/${srcDirName}`,
17 | releaseDir: `${root}/${releaseDirName}`,
18 | release : {
19 | root : `${root}/${releaseDirName}`
20 | },
21 | releaseDirName: releaseDirName,
22 | app: {
23 | entryPoint : `${srcDirName}/ngStomp.js`,
24 | name: appName
25 | },
26 | glob: {
27 | js : `${root}/${srcDirName}/${appName}/**/!(*.spec).js`
28 | },
29 | coverage : {
30 | lcovfile : 'reports/coverage/phantomjs/lcov.info'
31 | }
32 | }
33 |
--------------------------------------------------------------------------------
/build/tasks/build.js:
--------------------------------------------------------------------------------
1 | import gulp from "gulp";
2 | import jspm from 'jspm';
3 | import sourcemaps from 'gulp-sourcemaps';
4 | import ngAnnotate from 'gulp-ng-annotate';
5 | import uglify from 'gulp-uglify';
6 | import rename from 'gulp-rename';
7 | import runSequence from 'run-sequence';
8 | import del from 'del';
9 | import mkdirp from 'mkdirp';
10 | import paths from '../paths';
11 |
12 | gulp.task('build:pre-clean', (cb) => del([`${paths.releaseDir}/**/*`], cb));
13 | gulp.task('build:create-folder', (cal) => mkdirp(paths.release.root, (err) => (err) ? cal(new Error(err)) : cal()));
14 |
15 | gulp.task('build:jspm', (cb) => {
16 | let options = {
17 | sourceMaps: true,
18 | globalDeps: { angular : 'angular', stompjs : 'Stomp' },
19 | formatHint: true
20 | };
21 |
22 | new jspm.Builder()
23 | .buildStatic(`${paths.app.entryPoint} - angular - stompjs`, `${paths.releaseDir}/${paths.app.name}.js`, options)
24 | .then(() => cb())
25 | .catch((ex) => cb(new Error(ex)));
26 | });
27 |
28 | gulp.task('build:js', () =>
29 | gulp.src(`${paths.releaseDir}/${paths.app.name}.js`)
30 | .pipe(ngAnnotate())
31 | .pipe(gulp.dest(paths.releaseDir))
32 | .pipe(sourcemaps.init({loadMaps: true}))
33 | .pipe(uglify())
34 | .pipe(rename({suffix: '.min'}))
35 | .pipe(sourcemaps.write('.'))
36 | .pipe(gulp.dest(paths.releaseDir))
37 | );
38 |
39 | gulp.task('build:post-clean', (cb) => del([`${paths.releaseDir}/${paths.app.name}.js.map`], cb));
40 |
41 | gulp.task('build', (cal) => {
42 | runSequence(
43 | ['build:pre-clean'],
44 | ['build:create-folder'],
45 | ['build:jspm'],
46 | ['build:js'],
47 | ['build:post-clean'],
48 | cal);
49 | });
50 |
--------------------------------------------------------------------------------
/build/tasks/coveralls.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by kevin on 27/12/2015.
3 | */
4 | import gulp from 'gulp';
5 | import coveralls from 'gulp-coveralls';
6 | import paths from '../paths';
7 |
8 | gulp.task('coveralls', () =>
9 | gulp.src(paths.coverage.lcovfile)
10 | .pipe(coveralls())
11 | );
--------------------------------------------------------------------------------
/build/tasks/lint.js:
--------------------------------------------------------------------------------
1 | import gulp from 'gulp';
2 | import paths from '../paths';
3 | import eslint from 'gulp-eslint';
4 |
5 | gulp.task('lint:js', () =>
6 | gulp.src([paths.glob.js])
7 | .pipe(eslint())
8 | .pipe(eslint.format())
9 | );
10 |
--------------------------------------------------------------------------------
/build/tasks/release.js:
--------------------------------------------------------------------------------
1 | import gulp from 'gulp';
2 | import util from 'gulp-util';
3 | import semver from 'semver';
4 | import paths from '../paths';
5 | import conventionalChangelog from 'gulp-conventional-changelog';
6 | import bump from 'gulp-bump';
7 | import git from 'gulp-git';
8 | import runSequence from 'run-sequence';
9 |
10 | import pkg from '../../package.json';
11 | import bowerJson from '../../bower.json';
12 |
13 | let argv = util.env;
14 |
15 | gulp.task('bump', (cb) => {
16 | if (!semver.valid(pkg.version)) {
17 | util.log(util.colors.red(`Error: Invalid version number - ${pkg.version}`));
18 | return process.exit(1);
19 | }
20 |
21 | let hasValidType = !!argv.type ? !!argv.type.match(new RegExp(/major|minor|patch/)) : false;
22 | if (!hasValidType) {
23 | util.log(util.colors.red('Error: Required bump \'type\' is missing! Usage: npm run release --type (major|minor|patch)'));
24 | return process.exit(1);
25 | }
26 |
27 | pkg.version = semver.inc(pkg.version, argv.type);
28 | gulp.src([paths.packageJson, paths.bowerJson])
29 | .pipe(bump({ version: pkg.version }))
30 | .pipe(gulp.dest('./'))
31 | .on('end', cb);
32 | });
33 |
34 | gulp.task('changelog', (cb) => {
35 | gulp.src(`${paths.root}/CHANGELOG.md`, { buffer: false })
36 | .pipe(conventionalChangelog({ preset: 'angular' }))
37 | .pipe(gulp.dest('./'))
38 | .on('end', cb);
39 | });
40 |
41 | gulp.task('commit-changelog', (cb) => {
42 | let sources = [ `${paths.root}/CHANGELOG.md`, `${paths.root}/package.json`, `${paths.root}/bower.json` ];
43 | gulp.src(sources)
44 | .pipe(git.add())
45 | .pipe(git.commit(`chore(release): ${pkg.version}`))
46 | .on('end', cb);
47 | });
48 |
49 | gulp.task('create-version-tag', (cb) => {
50 | git.tag(`v${pkg.version}`, `release v${pkg.version}`, (err) => {
51 | if (err) throw err;
52 | cb();
53 | });
54 | });
55 |
56 | gulp.task('push-to-origin', (cb) => {
57 | git.push('origin', 'master', { args: '--tags' }, (err) => {
58 | if (err) throw err;
59 | cb();
60 | });
61 | });
62 |
63 | gulp.task('release', (cb) => {
64 | runSequence('bump', 'changelog', 'commit-changelog', 'create-version-tag', 'push-to-origin', cb);
65 | });
66 |
--------------------------------------------------------------------------------
/config.js:
--------------------------------------------------------------------------------
1 | System.config({
2 | baseURL: "/",
3 | defaultJSExtensions: true,
4 | transpiler: "babel",
5 | babelOptions: {
6 | "stage": 0,
7 | "optional": [
8 | "runtime",
9 | "optimisation.modules.system"
10 | ]
11 | },
12 | paths: {
13 | "github:*": "jspm_packages/github/*",
14 | "npm:*": "jspm_packages/npm/*"
15 | },
16 |
17 | map: {
18 | "angular": "github:angular/bower-angular@1.4.8",
19 | "angular-mocks": "github:angular/bower-angular-mocks@1.4.8",
20 | "babel": "npm:babel-core@5.8.34",
21 | "babel-runtime": "npm:babel-runtime@5.8.34",
22 | "core-js": "npm:core-js@1.2.6",
23 | "stompjs": "github:jmesnil/stomp-websocket@2.3.4",
24 | "github:angular/bower-angular-mocks@1.4.8": {
25 | "angular": "github:angular/bower-angular@1.4.8"
26 | },
27 | "github:jspm/nodelibs-assert@0.1.0": {
28 | "assert": "npm:assert@1.3.0"
29 | },
30 | "github:jspm/nodelibs-path@0.1.0": {
31 | "path-browserify": "npm:path-browserify@0.0.0"
32 | },
33 | "github:jspm/nodelibs-process@0.1.2": {
34 | "process": "npm:process@0.11.2"
35 | },
36 | "github:jspm/nodelibs-util@0.1.0": {
37 | "util": "npm:util@0.10.3"
38 | },
39 | "npm:assert@1.3.0": {
40 | "util": "npm:util@0.10.3"
41 | },
42 | "npm:babel-runtime@5.8.34": {
43 | "process": "github:jspm/nodelibs-process@0.1.2"
44 | },
45 | "npm:core-js@1.2.6": {
46 | "fs": "github:jspm/nodelibs-fs@0.1.2",
47 | "path": "github:jspm/nodelibs-path@0.1.0",
48 | "process": "github:jspm/nodelibs-process@0.1.2",
49 | "systemjs-json": "github:systemjs/plugin-json@0.1.0"
50 | },
51 | "npm:inherits@2.0.1": {
52 | "util": "github:jspm/nodelibs-util@0.1.0"
53 | },
54 | "npm:path-browserify@0.0.0": {
55 | "process": "github:jspm/nodelibs-process@0.1.2"
56 | },
57 | "npm:process@0.11.2": {
58 | "assert": "github:jspm/nodelibs-assert@0.1.0"
59 | },
60 | "npm:util@0.10.3": {
61 | "inherits": "npm:inherits@2.0.1",
62 | "process": "github:jspm/nodelibs-process@0.1.2"
63 | }
64 | }
65 | });
66 |
--------------------------------------------------------------------------------
/core/builder.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by kevin on 14/12/2015.
3 | */
4 | import UnSubscriber from './unSubscriber';
5 | import angular from 'angular';
6 |
7 | export default class SubscribeBuilder {
8 |
9 | /*@ngNoInject*/
10 | constructor(ngStomp, queue) {
11 | this.ngStomp = ngStomp;
12 | this.connections = [];
13 |
14 | this.subscribeTo(queue);
15 | }
16 |
17 | callback(aCallback) {
18 | this.aCallback = aCallback;
19 | return this;
20 | }
21 |
22 | withHeaders(headers) {
23 | this.headers = headers;
24 | return this;
25 | }
26 |
27 | bindTo(aScope) {
28 | this.scope = aScope;
29 | return this;
30 | }
31 |
32 | withBodyInJson() {
33 | this.json = true;
34 | return this;
35 | }
36 |
37 | withDigest(digest) {
38 | this.digest = digest;
39 | return this;
40 | }
41 |
42 | build() {
43 | return this.connect();
44 | }
45 |
46 | subscribeTo(queue) {
47 | this.queue = queue;
48 | this.aCallback = angular.noop;
49 | this.headers = {};
50 | this.scope = undefined;
51 | this.json = false;
52 | this.digest = true;
53 |
54 | return this;
55 | }
56 |
57 | connect() {
58 | this.and();
59 | this.connections.forEach(c => this.ngStomp.subscribe(c.queue, c.callback, c.headers, c.scope, c.json, c.digest));
60 | return new UnSubscriber(this.ngStomp, this.connections);
61 | }
62 |
63 | and() {
64 | this.connections.push({
65 | queue : this.queue,
66 | callback : this.aCallback,
67 | headers : this.headers,
68 | scope : this.scope,
69 | json : this.json,
70 | digest : this.digest,
71 | index : this.connections.length
72 | });
73 | return this;
74 | }
75 | }
--------------------------------------------------------------------------------
/core/builder.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by kevin on 15/12/2015.
3 | */
4 | //import {describe, it, expect} from 'jasmine';
5 | import angular from 'angular';
6 | import Builder from './builder';
7 |
8 | describe('Builder', () => {
9 |
10 | let ngStomp = { subscribe : x => x}, firstTopic = 'aTopic', secondTopic = 'secondTopic';
11 | let builder;
12 |
13 | let transformToConnection = (queue, callback, headers, scope, json, digest, index) => ({queue, callback, headers, scope, json, digest, index });
14 |
15 | beforeEach(() => {
16 | spyOn(ngStomp, 'subscribe').and.returnValue(new Builder(ngStomp, secondTopic));
17 | builder = new Builder(ngStomp, firstTopic);
18 | });
19 |
20 | it('should construct a coherent object', () => {
21 | expect(builder.ngStomp).toBe(ngStomp);
22 | expect(builder.queue).toBe(firstTopic);
23 | });
24 |
25 | it('should subscribe with default parameters', () => {
26 | builder.build();
27 | expect(ngStomp.subscribe.calls.mostRecent().args).toEqual([firstTopic, angular.noop, {}, undefined, false, true])
28 | });
29 |
30 | it('should subscribe', () => {
31 | let aCallback = x => x,
32 | headers = { foo : 'foo', bar : 'bar'},
33 | $scope = {};
34 |
35 | let unSubscriber = builder
36 | .callback(aCallback)
37 | .withHeaders(headers)
38 | .bindTo($scope)
39 | .withBodyInJson()
40 | .connect();
41 |
42 | expect(ngStomp.subscribe.calls.mostRecent().args).toEqual([firstTopic, aCallback, headers, $scope, true, true]);
43 | expect(unSubscriber.connections).toEqual([transformToConnection(firstTopic, aCallback, headers, $scope, true, true, 0)]);
44 | });
45 |
46 | it('should subscribe with chaining', () => {
47 | let aCallback = x => x,
48 | headers = { foo : 'foo', bar : 'bar'},
49 | $scope = {};
50 |
51 | let unSubscriber = builder
52 | .callback(aCallback)
53 | .withHeaders(headers)
54 | .bindTo($scope)
55 | .and()
56 | .subscribeTo(secondTopic)
57 | .callback(angular.noop)
58 | .withDigest(false)
59 | .connect();
60 |
61 | expect(ngStomp.subscribe.calls.argsFor(0)).toEqual([firstTopic, aCallback, headers, $scope, false, true]);
62 | expect(ngStomp.subscribe.calls.argsFor(1)).toEqual([secondTopic, angular.noop, {}, undefined, false, false]);
63 |
64 | expect(unSubscriber.connections).toEqual([
65 | transformToConnection(firstTopic, aCallback, headers, $scope, false, true, 0),
66 | transformToConnection(secondTopic, angular.noop, {}, undefined, false, false, 1)
67 | ]);
68 | });
69 |
70 |
71 | });
72 |
--------------------------------------------------------------------------------
/core/ngStomp.js:
--------------------------------------------------------------------------------
1 | import angular from 'angular';
2 | import Stomp from 'stompjs';
3 | import ngstompProvider from './provider';
4 |
5 | export default angular
6 | .module('AngularStompDK', [])
7 | .provider('ngstomp', ngstompProvider)
8 | .constant('Stomp', Stomp);
--------------------------------------------------------------------------------
/core/ngStomp.spec.js:
--------------------------------------------------------------------------------
1 | //import {describe, it, expect} from 'jasmine';
2 | import AngularStompDK from './ngStomp';
3 | import 'angular-mocks';
4 |
5 | describe('angular-stomp', () => {
6 |
7 | let Stomp;
8 | let ngstompProvider;
9 |
10 | beforeEach(module(AngularStompDK.name, (_ngstompProvider_) => {
11 | ngstompProvider = _ngstompProvider_;
12 | }));
13 |
14 | describe('Provider', () => {
15 |
16 | beforeEach(inject());
17 |
18 | it('should have a provider', () => {
19 | expect(ngstompProvider).toBeDefined();
20 | expect(ngstompProvider.$get).toBeDefined();
21 | });
22 | });
23 |
24 | describe('Stomp', () => {
25 |
26 | beforeEach(inject((_Stomp_) => {
27 | Stomp = _Stomp_;
28 | }));
29 |
30 | it('should have a service', () => {
31 | expect(Stomp).toBeDefined();
32 | });
33 | });
34 |
35 | });
--------------------------------------------------------------------------------
/core/provider.js:
--------------------------------------------------------------------------------
1 | import ngStompWebSocket from './service';
2 |
3 | export default class ngstompProvider {
4 |
5 | settings = {
6 | timeOut : 5000,
7 | heartbeat : { outgoing: 10000, incoming: 10000},
8 | autoConnect : true
9 | };
10 |
11 | constructor() {}
12 |
13 | credential(login, password) {
14 | this.settings.login = login;
15 | this.settings.password = password;
16 | return this;
17 | }
18 |
19 | url(url) {
20 | this.settings.url = url;
21 | return this;
22 | }
23 |
24 | class(clazz) {
25 | this.settings.class = clazz;
26 | return this;
27 | }
28 |
29 | setting(settingsObject) {
30 | this.settings = settingsObject;
31 | return this;
32 | }
33 |
34 | debug(boolean) {
35 | this.settings.debug = boolean;
36 | return this;
37 | }
38 |
39 | vhost(host) {
40 | this.settings.vhost = host;
41 | return this;
42 | }
43 |
44 | reconnectAfter(numberInSeconds) {
45 | this.settings.timeOut = numberInSeconds * 1000;
46 | return this;
47 | }
48 |
49 | heartbeat(outgoing, incoming) {
50 | this.settings.heartbeat.outgoing = outgoing;
51 | this.settings.heartbeat.incoming = incoming;
52 | return this;
53 | }
54 |
55 | autoConnect(autoConnectionDefaultValue) {
56 | this.settings.autoConnect = autoConnectionDefaultValue;
57 | return this;
58 | }
59 |
60 | headers(headers) {
61 | this.settings.headers = headers;
62 | return this;
63 | }
64 |
65 | $get($q, $log, $rootScope, $timeout, Stomp) {
66 | "ngInject";
67 | return new ngStompWebSocket(this.settings, $q, $log, $rootScope, $timeout, Stomp);
68 | }
69 | }
70 |
71 |
72 |
--------------------------------------------------------------------------------
/core/provider.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by kevin on 20/12/2015.
3 | */
4 | //import {describe, it, expect} from 'jasmine';
5 | import Provider from './provider';
6 | import angular from 'angular';
7 |
8 | describe('Provider', () => {
9 |
10 | let provider,
11 | Stomp = { client : x => x, over : x => x},
12 | $q = { defer : x => x, reject : x => x },
13 | defered = { promise : 'promise', reject : x => x},
14 | stompClient = { connect : x => x, heartbeat : {}},
15 | $log = {},
16 | $rootScope = {},
17 | $timeout;
18 |
19 | beforeEach(() => {
20 | $timeout = jasmine.createSpy('$timeout');
21 | spyOn($q, 'defer').and.returnValue(defered);
22 | spyOn($q, 'reject').and.returnValue(defered);
23 | spyOn(Stomp, 'client').and.returnValue(stompClient);
24 | spyOn(Stomp, 'over').and.returnValue(stompClient);
25 | provider = new Provider();
26 | });
27 |
28 | it('should be auto configured', () => {
29 | const connectionUrl = '/anUrl';
30 |
31 | let ngStomp = provider
32 | .url(connectionUrl)
33 | .$get($q, $log, $rootScope, $timeout, Stomp);
34 |
35 | expect(ngStomp.settings)
36 | .toEqual(angular.extend(
37 | {},
38 | { url : connectionUrl },
39 | { timeOut : 5000, heartbeat : { outgoing : 10000, incoming : 10000 }, autoConnect : true }
40 | ));
41 | });
42 |
43 | it('should be configured by fluent api', () => {
44 | const connectionUrl = '/anotherUrl',
45 | login = 'login', password = 'password',
46 | vhost = 'vhost',
47 | headers = {foo: 'bar'};
48 |
49 | let ngStomp = provider
50 | .url(connectionUrl)
51 | .credential(login, password)
52 | .reconnectAfter(10)
53 | .class(angular.noop)
54 | .debug(true)
55 | .vhost(vhost)
56 | .heartbeat(1, 2)
57 | .autoConnect(false)
58 | .headers(headers)
59 | .$get($q, $log, $rootScope, $timeout, Stomp);
60 |
61 | expect(ngStomp.settings).toEqual({
62 | "timeOut" : 10000,
63 | "url": connectionUrl,
64 | "login": login,
65 | "password": password,
66 | "class": angular.noop,
67 | "debug": true,
68 | "vhost": vhost,
69 | "heartbeat": {
70 | "outgoing": 1,
71 | "incoming": 2
72 | },
73 | "headers": headers,
74 | "autoConnect" : false
75 | });
76 | });
77 |
78 | it('should be configured by settings', () => {
79 | let settingsObject = { an : 'object'};
80 | provider.setting(settingsObject);
81 | expect(settingsObject).toBe(provider.settings);
82 | });
83 |
84 | it('should have auto-connect parameter', () => {
85 | let settingsObject = { an : 'object'};
86 | provider.setting(settingsObject);
87 | expect(settingsObject).toBe(provider.settings);
88 | });
89 | });
90 |
--------------------------------------------------------------------------------
/core/service.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by kevin on 14/12/2015.
3 | */
4 | import SubscribeBuilder from './builder';
5 | import angular from 'angular';
6 |
7 | export default class ngStompWebSocket {
8 |
9 | /*@ngNoInject*/
10 | constructor(settings, $q, $log, $rootScope, $timeout, Stomp) {
11 | this.settings = settings;
12 | this.$q = $q;
13 | this.$rootScope = $rootScope;
14 | this.$log = $log;
15 | this.Stomp = Stomp;
16 | this.$timeout = $timeout;
17 | this.connections = [];
18 |
19 | this.$initConnectionState();
20 | if (settings.autoConnect) {
21 | this.connect();
22 | }
23 | }
24 |
25 | connect() {
26 | this.$initConnectionState();
27 | return this.$connect();
28 | }
29 |
30 | $initConnectionState() {
31 | this.deferred && this.deferred.reject();
32 | this.deferred = this.$q.defer();
33 | this.connectionState = this.deferred.promise;
34 | }
35 |
36 | $connect() {
37 | this.$setConnection();
38 |
39 | let successCallback = () => this.deferred.resolve();
40 | let errorCallback = () => {
41 | this.deferred.reject();
42 | this.$initConnectionState();
43 | this.settings.timeOut >= 0 && this.$timeout(() => {
44 | this.$connect();
45 | this.$reconnectAll();
46 | }, this.settings.timeOut);
47 | };
48 |
49 | if (angular.isDefined(this.settings.headers)) {
50 | this.stompClient.connect(
51 | this.settings.headers,
52 | successCallback,
53 | errorCallback
54 | )
55 | } else {
56 | this.stompClient.connect(
57 | this.settings.login,
58 | this.settings.password,
59 | successCallback,
60 | errorCallback,
61 | this.settings.vhost
62 | );
63 | }
64 |
65 |
66 | return this.connectionState;
67 | }
68 |
69 | subscribe(queue, callback, header = {}, scope, json = false, digest) {
70 | this.connectionState
71 | .then(
72 | () => this.$stompSubscribe(queue, callback, header, scope, json, digest),
73 | () => this.$$addToConnectionQueue({ queue, callback, header, scope, json, digest })
74 | )
75 | ;
76 | return this;
77 | }
78 |
79 | subscribeTo(topic) {
80 | return new SubscribeBuilder(this, topic);
81 | }
82 |
83 | /* Deprecated */
84 | unsubscribe(url) {
85 | this.connectionState.then(() => this.$stompUnSubscribe(url));
86 | return this;
87 | }
88 |
89 | send(queue, data, header = {}) {
90 | let sendDeffered = this.$q.defer();
91 |
92 | this.connectionState.then(() => {
93 | this.stompClient.send(queue, header, JSON.stringify(data));
94 | sendDeffered.resolve();
95 | });
96 |
97 | return sendDeffered.promise;
98 | }
99 |
100 | disconnect() {
101 | let disconnectionPromise = this.$q.defer();
102 | this.stompClient.disconnect(() => {
103 | disconnectionPromise.resolve();
104 | });
105 |
106 | return disconnectionPromise.promise;
107 | }
108 |
109 | set login(login) {
110 | this.settings.login = login;
111 | }
112 |
113 | set password(password) {
114 | this.settings.password = password;
115 | }
116 |
117 | set url(url) {
118 | this.settings.url = url;
119 | }
120 |
121 | $stompSubscribe(queue, callback, header, scope = this.$rootScope, json, digest) {
122 | let sub = this.stompClient.subscribe(queue, message => {
123 | if (json) message.body = JSON.parse(message.body);
124 |
125 | if (digest) {
126 | scope.$applyAsync(() => callback(message));
127 | } else {
128 | callback(message);
129 | }
130 | }, header);
131 |
132 | let connection = { queue, sub, callback, header, scope, json, digest};
133 | this.$$addToConnectionQueue(connection);
134 | this.$unRegisterScopeOnDestroy(connection);
135 | }
136 |
137 | $stompUnSubscribe(queue) {
138 | this.connections
139 | .filter(c => c.queue === queue)
140 | .forEach(c => c.sub.unsubscribe());
141 |
142 | this.connections = this.connections.filter(c => c.queue != queue);
143 | }
144 |
145 | $setConnection() {
146 | this.stompClient = this.settings.class ? this.Stomp.over(new this.settings.class(this.settings.url)) : this.Stomp.client(this.settings.url);
147 | this.stompClient.debug = (this.settings.debug) ? this.$log.debug : angular.noop;
148 | if (angular.isDefined(this.settings.heartbeat)) {
149 | this.stompClient.heartbeat.outgoing = this.settings.heartbeat.outgoing;
150 | this.stompClient.heartbeat.incoming = this.settings.heartbeat.incoming;
151 | }
152 | }
153 |
154 | $unRegisterScopeOnDestroy(connection) {
155 | if (connection.scope !== undefined && angular.isFunction(connection.scope.$on))
156 | connection.scope.$on('$destroy', () => this.$$unSubscribeOf(connection) );
157 | }
158 |
159 | $reconnectAll() {
160 | let connections = this.connections;
161 | this.connections = [];
162 | // during subscription each connection will be added to this.connections array again
163 | connections.forEach(c => this.subscribe(c.queue, c.callback, c.header, c.scope, c.json, c.digest));
164 | }
165 |
166 | $$unSubscribeOf(connection) {
167 | this.connections
168 | .filter(c => this.$$connectionEquality(c, connection))
169 | .forEach(c => c.sub.unsubscribe());
170 |
171 | this.connections = this.connections.filter(c => !this.$$connectionEquality(c, connection));
172 | }
173 |
174 | $$addToConnectionQueue(connection) {
175 | this.connections.push(connection);
176 | }
177 |
178 | $$connectionEquality(c1, c2) {
179 | return c1.queue === c2.queue
180 | && c1.callback === c2.callback
181 | && c1.header === c2.header
182 | && c1.scope === c2.scope
183 | && c1.digest === c2.digest;
184 | }
185 | }
--------------------------------------------------------------------------------
/core/service.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by kevin on 21/12/2015.
3 | */
4 | //import {describe, it, expect} from 'jasmine';
5 | import NgStomp from './service';
6 | import angular from 'angular';
7 |
8 | describe('Service', () => {
9 |
10 | let settings = {
11 | "url": "http://connection.com/url",
12 | "login": "login",
13 | "password": "password",
14 | "class": angular.noop,
15 | "debug": true,
16 | "vhost": "vhost",
17 | "timeOut" : 5000,
18 | "heartbeat": {
19 | "outgoing": 1,
20 | "incoming": 2
21 | },
22 | "autoConnect" : true
23 | };
24 |
25 | let Stomp = { client : x => x, over : x => x},
26 | $q = { defer : x => x, reject : x => x },
27 | promise = { then : func => func() },
28 | defered = { promise : promise, resolve : angular.noop, reject : angular.noop},
29 | aConnection = { unsubscribe : angular.noop },
30 | stompClient = { connect : x => x, heartbeat : {}, subscribe : () => aConnection, send : angular.noop, disconnect : func => func() },
31 | $log = {},
32 | $rootScope = { $$phase : false, $apply : angular.noop, $applyAsync : func => func() },
33 | $timeout;
34 |
35 | let ngStomp;
36 |
37 | beforeEach(() => {
38 | $timeout = jasmine.createSpy('$timeout');
39 | spyOn($q, 'defer').and.returnValue(defered);
40 | spyOn($q, 'reject').and.returnValue(defered);
41 | spyOn(defered, 'resolve').and.callThrough();
42 | spyOn(defered, 'reject').and.callThrough();
43 | spyOn(promise, 'then').and.callThrough();
44 | spyOn(Stomp, 'client').and.returnValue(stompClient);
45 | spyOn(Stomp, 'over').and.returnValue(stompClient);
46 | spyOn(stompClient, 'connect').and.callThrough();
47 | spyOn(stompClient, 'subscribe').and.callThrough();
48 | spyOn(stompClient, 'send').and.callThrough();
49 | spyOn(stompClient, 'disconnect').and.callThrough();
50 | spyOn($rootScope, '$apply').and.callThrough();
51 | spyOn($rootScope, '$applyAsync').and.callThrough();
52 | spyOn(aConnection, 'unsubscribe').and.callThrough();
53 | });
54 |
55 | describe('connect', () => {
56 |
57 | describe('with login / password', () => {
58 |
59 | beforeEach(() => {
60 | ngStomp = new NgStomp(angular.copy(settings), $q, $log, $rootScope, $timeout, Stomp);
61 | });
62 |
63 | it('should be defined with custom settings', () => {
64 | ngStomp = new NgStomp({
65 | "url": "http://connection.com/url",
66 | "login": "login",
67 | "password": "password",
68 | "class": angular.noop,
69 | "debug": true,
70 | "vhost": "vhost",
71 | "autoConnect": true
72 | }, $q, $log, $rootScope, $timeout, Stomp);
73 | expect(stompClient.connect.calls.argsFor(0)[0]).toEqual(settings.login);
74 | expect(stompClient.connect.calls.argsFor(0)[1]).toEqual(settings.password);
75 | expect(stompClient.connect.calls.argsFor(0)[4]).toEqual(settings.vhost);
76 | });
77 |
78 | it('should be coherent object', () => {
79 | expect(ngStomp).toBeDefined();
80 | expect(stompClient.connect.calls.argsFor(0)[0]).toEqual(settings.login);
81 | expect(stompClient.connect.calls.argsFor(0)[1]).toEqual(settings.password);
82 | expect(stompClient.connect.calls.argsFor(0)[4]).toEqual(settings.vhost);
83 | });
84 |
85 | it('should have promise resolved if stomp connected', () => {
86 | let success = stompClient.connect.calls.argsFor(0)[2];
87 | success();
88 | expect(defered.resolve).toHaveBeenCalled();
89 | });
90 | });
91 |
92 | describe('with headers', () => {
93 |
94 | let settingsWithHeaders = angular.extend({}, settings, {headers: {foo:'Bar'}});
95 |
96 | beforeEach(() => {
97 | ngStomp = new NgStomp(settingsWithHeaders, $q, $log, $rootScope, $timeout, Stomp);
98 | });
99 |
100 | it('should connect with headers instead of login / password', () => {
101 | expect(stompClient.connect.calls.argsFor(0)[0]).toEqual({foo: 'Bar'});
102 | });
103 |
104 | });
105 |
106 |
107 | });
108 |
109 | describe('subscribe', () => {
110 |
111 | beforeEach(() => {
112 | ngStomp = new NgStomp(angular.copy(settings), $q, $log, $rootScope, $timeout, Stomp);
113 | });
114 |
115 | it('should subscribe', () => {
116 | /* Given */
117 | let pivotValue = 0,
118 | callBack = () => pivotValue = 10;
119 |
120 | let $scope = { $applyAsync : func => func() };
121 | spyOn($scope, '$applyAsync').and.callThrough();
122 |
123 | /* When */
124 | ngStomp.subscribe('/topic/foo', callBack, {}, $scope, false, true);
125 | stompClient.subscribe.calls.mostRecent().args[1]();
126 |
127 | /* Then */
128 | expect(pivotValue).toBe(10);
129 | expect(ngStomp.connections.filter(c => c.queue ==='/topic/foo').length > 0).toBeTruthy();
130 | expect($scope.$applyAsync).toHaveBeenCalled();
131 | });
132 |
133 | it('should subscribe with json', () => {
134 | /* Given */
135 | let pivotValue = 0,
136 | callBack = (val) => pivotValue = val.body.a;
137 |
138 | /* When */
139 | ngStomp.subscribe('/topic/foo', callBack, {}, { $applyAsync : func => func() }, true, true);
140 | stompClient.subscribe.calls.mostRecent().args[1]({ body : "{ \"a\":10, \"b\":5 }"});
141 |
142 | /* Then */
143 | expect(pivotValue).toBe(10);
144 | expect(ngStomp.connections.filter(c => c.queue ==='/topic/foo').length > 0).toBeTruthy();
145 | });
146 |
147 | it('should subscribe without digest cycle', () => {
148 | /* Given */
149 | let pivotValue = 0, callBack = (val) => pivotValue = val.body.a;
150 | let $scope = { $applyAsync : func => func() };
151 | spyOn($scope, '$applyAsync').and.callThrough();
152 |
153 |
154 | /* When */
155 | ngStomp.subscribe('/topic/foo', callBack, {}, $scope, true, false);
156 | stompClient.subscribe.calls.mostRecent().args[1]({ body : "{ \"a\":10, \"b\":5 }"});
157 |
158 | /* Then */
159 | expect(pivotValue).toBe(10);
160 | expect(ngStomp.connections.filter(c => c.queue ==='/topic/foo').length > 0).toBeTruthy()
161 | expect($scope.$applyAsync).not.toHaveBeenCalled();
162 | });
163 |
164 | it('should return builder on subscribeTo', () => {
165 | let builder = ngStomp.subscribeTo('aTopic');
166 | expect(builder.queue).toBe('aTopic');
167 | });
168 | });
169 |
170 | describe('with connection failed at boot up', () => {
171 |
172 | let $q = {defer : x => x }, defferedWitchReject = {
173 | promise : { then : (_, func) => func() },
174 | resolve : angular.noop,
175 | reject : angular.noop
176 | };
177 |
178 | beforeEach(() => {
179 | spyOn($q, 'defer').and.returnValue(defferedWitchReject);
180 | spyOn(defferedWitchReject, 'resolve').and.callThrough();
181 | spyOn(defferedWitchReject, 'reject').and.callThrough();
182 | spyOn(defferedWitchReject.promise, 'then').and.callThrough();
183 | ngStomp = new NgStomp(angular.copy(settings), $q, $log, $rootScope, $timeout, Stomp);
184 | });
185 |
186 | it('should save connection if connection failed', () => {
187 | /* Given */
188 | let pivotValue = 0, callBack = (val) => pivotValue = val.body.a;
189 | /* When */
190 | ngStomp.subscribe('/topic/foo', callBack, {}, {});
191 |
192 | /* Then */
193 | expect(ngStomp.connections.length).toBe(1);
194 | });
195 |
196 | });
197 |
198 | describe('unsubscribe', () => {
199 |
200 | beforeEach(() => {
201 | ngStomp = new NgStomp(angular.copy(settings), $q, $log, $rootScope, $timeout, Stomp);
202 | });
203 |
204 | it('should unsubscribe from topic', () => {
205 | ngStomp.subscribe('/topic/foo', angular.noop, {}, {});
206 | ngStomp.unsubscribe('/topic/foo');
207 |
208 | expect(aConnection.unsubscribe).toHaveBeenCalled();
209 | });
210 |
211 | it('should unsubscribe if scope is destroyed', () => {
212 | let aScope = { $on : angular.noop };
213 | spyOn(aScope, '$on').and.callThrough();
214 |
215 | ngStomp.subscribe('/topic/foo', angular.noop, undefined, aScope);
216 | aScope.$on.calls.mostRecent().args[1]();
217 |
218 | expect(aScope.$on).toHaveBeenCalled();
219 | expect(aScope.$on.calls.mostRecent().args[0]).toBe('$destroy');
220 | expect(aConnection.unsubscribe).toHaveBeenCalled();
221 | });
222 |
223 | it('should unsubscribe from unsubscriber', () => {
224 | /* Given */
225 | let topic = 'foo';
226 | let callback1 = x => x, header1 = {}, scope1 = {}, sub1 = jasmine.createSpyObj('sub1', ['unsubscribe']),
227 | callback2 = y => y, header2 = {}, scope2 = {}, sub2 = jasmine.createSpyObj('sub2', ['unsubscribe']),
228 | callback3 = y => y, header3 = {}, scope3 = {}, sub3 = jasmine.createSpyObj('sub3', ['unsubscribe']);
229 |
230 | ngStomp.connections = [
231 | {queue : topic, callback : callback1, header : header1, scope : scope1, sub : sub1},
232 | {queue : topic, callback : callback2, header : header2, scope : scope2, sub : sub2},
233 | {queue : 'bar', callback : callback3, header : header3, scope : scope3, sub : sub3}
234 | ];
235 |
236 | /* When */
237 | ngStomp.$$unSubscribeOf({queue : topic, callback : callback2, header : header2, scope : scope2});
238 |
239 | /* Then */
240 | expect(sub1.unsubscribe).not.toHaveBeenCalled();
241 | expect(sub2.unsubscribe).toHaveBeenCalled();
242 | expect(sub3.unsubscribe).not.toHaveBeenCalled();
243 | expect(ngStomp.connections.length).toBe(2);
244 | });
245 |
246 | });
247 |
248 | describe('when subscribed', () => {
249 |
250 | beforeEach(() => {
251 | ngStomp = new NgStomp(angular.copy(settings), $q, $log, $rootScope, $timeout, Stomp);
252 | });
253 |
254 | beforeEach(() => {
255 | ngStomp.subscribe('/queue/foo', angular.noop);
256 | });
257 |
258 | it('should send data', () => {
259 | let aPromise = ngStomp.send('/queue/foo', { foo : 'bar', to : 'foo'}, {});
260 |
261 | expect(stompClient.send).toHaveBeenCalled();
262 | expect(aPromise).toBe(promise);
263 | });
264 |
265 | it('should send data without header', () => {
266 | let aPromise = ngStomp.send('/queue/foo', { foo : 'bar', to : 'foo'});
267 |
268 | expect(stompClient.send).toHaveBeenCalled();
269 | expect(aPromise).toBe(promise);
270 | });
271 |
272 | it('should disconnect', () => {
273 | let aPromise = ngStomp.disconnect();
274 | expect(stompClient.disconnect).toHaveBeenCalled();
275 | expect(aPromise).toBe(promise);
276 | });
277 |
278 | it('should handle a disconnection and reconnect after time defined in setting.timeOut if positive', () => {
279 | let connectionsCount = ngStomp.connections.length;
280 | let timeOutreconnectOnError = stompClient.connect.calls.argsFor(0)[3];
281 | $rootScope.$$phase = true;
282 |
283 |
284 | timeOutreconnectOnError();
285 | $timeout.calls.first().args[0]();
286 |
287 | expect($timeout.calls.first().args[1]).toBe(settings.timeOut);
288 | expect(stompClient.connect.calls.argsFor(1)[0]).toEqual(settings.login);
289 | expect(stompClient.connect.calls.argsFor(1)[1]).toEqual(settings.password);
290 | expect(stompClient.connect.calls.argsFor(1)[4]).toEqual(settings.vhost);
291 | expect(ngStomp.connections.length).toBe(connectionsCount);
292 | });
293 |
294 | it('should do noting on disconnection because of configuration', () => {
295 | let connectionsCount = ngStomp.connections.length;
296 | ngStomp.settings.timeOut = -1;
297 | let timeOutreconnectOnError = stompClient.connect.calls.argsFor(0)[3];
298 | $rootScope.$$phase = true;
299 |
300 | timeOutreconnectOnError();
301 |
302 | expect($timeout).not.toHaveBeenCalled();
303 | expect(stompClient.connect).toHaveBeenCalledTimes(1);
304 | expect(ngStomp.connections.length).toBe(connectionsCount);
305 | })
306 |
307 | });
308 |
309 | describe('when auto-connect disabled', () => {
310 |
311 | let settingWithoutAutoConnect = {};
312 |
313 | beforeEach(() => {
314 | settingWithoutAutoConnect = angular.extend({}, settings, {autoConnect : false});
315 | ngStomp = new NgStomp(angular.copy(settingWithoutAutoConnect), $q, $log, $rootScope, $timeout, Stomp);
316 | });
317 |
318 | it('should init without connect', () => {
319 | expect(Stomp.client).not.toHaveBeenCalled();
320 | });
321 |
322 | });
323 |
324 | describe('configuration', () => {
325 |
326 | beforeEach(() => {
327 | ngStomp = new NgStomp(angular.copy(settings), $q, $log, $rootScope, $timeout, Stomp);
328 | });
329 |
330 | it('should be able to change login / password / url with service', () => {
331 | /* Given */
332 | let login = 'foo', password = 'bar', url = 'http://a.fake.url/';
333 |
334 | /* When */
335 | ngStomp.login = login;
336 | ngStomp.password = password;
337 | ngStomp.url = url;
338 |
339 | /* Then */
340 | expect(ngStomp.settings.login).toBe(login);
341 | expect(ngStomp.settings.password).toBe(password);
342 | expect(ngStomp.settings.url).toBe(url);
343 | });
344 | });
345 |
346 |
347 | });
--------------------------------------------------------------------------------
/core/unSubscriber.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by kevin on 10/01/2016.
3 | */
4 |
5 | export default class Unsubscriber {
6 |
7 | constructor(ngStomp, connections) {
8 | this.ngStomp = ngStomp;
9 | this.connections = connections;
10 | }
11 |
12 | unSubscribeAll() {
13 | this.connections.forEach(c => this.$$unSubscribeOf(c));
14 | this.connections = [];
15 | }
16 |
17 | unSubscribeOf(queue) {
18 | this.connections
19 | .filter(c => c.queue === queue)
20 | .forEach(c => this.$$unSubscribeOf(c));
21 |
22 | this.connections = this.connections.filter(c => c.queue !== queue);
23 | }
24 |
25 | unSubscribeNth(index) {
26 | this.connections
27 | .filter(c => c.index === index)
28 | .forEach(c => this.$$unSubscribeOf(c));
29 |
30 | this.connections = this.connections.filter(c => c.index !== index);
31 | }
32 |
33 | $$unSubscribeOf(c) {
34 | this.ngStomp.$$unSubscribeOf({ queue: c.queue, callback: c.callback, header: c.headers, scope: c.scope, digest : c.digest});
35 | }
36 |
37 | }
--------------------------------------------------------------------------------
/core/unSubscriber.spec.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by kevin on 12/01/2016.
3 | */
4 | import UnSubscriber from './unSubscriber';
5 | import NgStomp from '../mock/ngStomp';
6 |
7 | describe('unSubscriber', () => {
8 |
9 | let ngStomp, connections, unSubscriber;
10 |
11 | beforeEach(() => {
12 | ngStomp = new NgStomp();
13 | connections = [];
14 | unSubscriber = new UnSubscriber(ngStomp, connections);
15 | });
16 |
17 | it('should have a coherent object', () => {
18 | /* Given */
19 | /* When */
20 | /* Then */
21 | expect(unSubscriber.ngStomp).toBe(ngStomp);
22 | expect(unSubscriber.connections).toBe(connections);
23 | });
24 |
25 | it('should unsubscribe All', () => {
26 | /* Given */
27 | connections.push({a : 'a'}, {b : 'b'}, {c : 'c'});
28 |
29 | /* When */
30 | unSubscriber.unSubscribeAll();
31 |
32 | /* Then */
33 | expect(ngStomp.spies.$$unSubscribeOf.calls.count()).toBe(3);
34 | expect(unSubscriber.connections).toEqual([]);
35 | });
36 |
37 | it('should unSubscribe from a topic', () => {
38 | /* Given */
39 | connections.push({queue : 'a', other : 'a'}, {queue : 'a', other : 'b'}, {queue : 'b'}, {queue : 'c'});
40 |
41 | /* When */
42 | unSubscriber.unSubscribeOf('a');
43 |
44 | /* Then */
45 | expect(ngStomp.spies.$$unSubscribeOf.calls.count()).toBe(2);
46 | expect(unSubscriber.connections).toEqual([{queue : 'b'}, {queue : 'c'}]);
47 | });
48 |
49 | it('should unSubscribe the nth registration', () => {
50 | /* Given */
51 | connections.push({queue : 'a', other : 'a', index : 1}, {queue : 'a', other : 'b', index : 2}, {queue : 'b', index : 3}, {queue : 'c', index : 4});
52 |
53 | /* When */
54 | unSubscriber.unSubscribeNth(2);
55 | unSubscriber.unSubscribeNth(1);
56 |
57 | /* Then */
58 | expect(ngStomp.spies.$$unSubscribeOf.calls.count()).toBe(2);
59 | expect(unSubscriber.connections.length).toBe(2);
60 | });
61 |
62 | });
--------------------------------------------------------------------------------
/dist/angular-stomp.js:
--------------------------------------------------------------------------------
1 | "format global";
2 | "globals.angular angular";
3 | "globals.Stomp stompjs";
4 |
5 | !function(e){function r(e,r,o){return 4===arguments.length?t.apply(this,arguments):void n(e,{declarative:!0,deps:r,declare:o})}function t(e,r,t,o){n(e,{declarative:!1,deps:r,executingRequire:t,execute:o})}function n(e,r){r.name=e,e in p||(p[e]=r),r.normalizedDeps=r.deps}function o(e,r){if(r[e.groupIndex]=r[e.groupIndex]||[],-1==v.call(r[e.groupIndex],e)){r[e.groupIndex].push(e);for(var t=0,n=e.normalizedDeps.length;n>t;t++){var a=e.normalizedDeps[t],u=p[a];if(u&&!u.evaluated){var d=e.groupIndex+(u.declarative!=e.declarative);if(void 0===u.groupIndex||u.groupIndex=0;a--){for(var u=t[a],i=0;ia;a++){var d=t.importers[a];if(!d.locked)for(var i=0;ia;a++){var l,s=r.normalizedDeps[a],c=p[s],v=x[s];v?l=v.exports:c&&!c.declarative?l=c.esModule:c?(d(c),v=c.module,l=v.exports):l=f(s),v&&v.importers?(v.importers.push(t),t.dependencies.push(v)):t.dependencies.push(null),t.setters[a]&&t.setters[a](l)}}}function i(e){var r,t=p[e];if(t)t.declarative?c(e,[]):t.evaluated||l(t),r=t.module.exports;else if(r=f(e),!r)throw new Error("Unable to load dependency "+e+".");return(!t||t.declarative)&&r&&r.__useDefault?r["default"]:r}function l(r){if(!r.module){var t={},n=r.module={exports:t,id:r.name};if(!r.executingRequire)for(var o=0,a=r.normalizedDeps.length;a>o;o++){var u=r.normalizedDeps[o],d=p[u];d&&l(d)}r.evaluated=!0;var c=r.execute.call(e,function(e){for(var t=0,n=r.deps.length;n>t;t++)if(r.deps[t]==e)return i(r.normalizedDeps[t]);throw new TypeError("Module "+e+" not declared as a dependency.")},t,n);c&&(n.exports=c),t=n.exports,t&&t.__esModule?r.esModule=t:r.esModule=s(t)}}function s(r){if(r===e)return r;var t={};if("object"==typeof r||"function"==typeof r)if(g){var n;for(var o in r)(n=Object.getOwnPropertyDescriptor(r,o))&&h(t,o,n)}else{var a=r&&r.hasOwnProperty;for(var o in r)(!a||r.hasOwnProperty(o))&&(t[o]=r[o])}return t["default"]=r,h(t,"__useDefault",{value:!0}),t}function c(r,t){var n=p[r];if(n&&!n.evaluated&&n.declarative){t.push(r);for(var o=0,a=n.normalizedDeps.length;a>o;o++){var u=n.normalizedDeps[o];-1==v.call(t,u)&&(p[u]?c(u,t):f(u))}n.evaluated||(n.evaluated=!0,n.module.execute.call(e))}}function f(e){if(D[e])return D[e];if("@node/"==e.substr(0,6))return y(e.substr(6));var r=p[e];if(!r)throw"Module "+e+" not present.";return a(e),c(e,[]),p[e]=void 0,r.declarative&&h(r.module.exports,"__esModule",{value:!0}),D[e]=r.declarative?r.module.exports:r.esModule}var p={},v=Array.prototype.indexOf||function(e){for(var r=0,t=this.length;t>r;r++)if(this[r]===e)return r;return-1},g=!0;try{Object.getOwnPropertyDescriptor({a:0},"a")}catch(m){g=!1}var h;!function(){try{Object.defineProperty({},"a",{})&&(h=Object.defineProperty)}catch(e){h=function(e,r,t){try{e[r]=t.value||t.get.call(e)}catch(n){}}}}();var x={},y="undefined"!=typeof System&&System._nodeRequire||"undefined"!=typeof require&&require.resolve&&"undefined"!=typeof process&&require,D={"@empty":{}};return function(e,n,o){return function(a){a(function(a){for(var u={_nodeRequire:y,register:r,registerDynamic:t,get:f,set:function(e,r){D[e]=r},newModule:function(e){return e}},d=0;d1)for(var d=1;d= 0 && _this.$timeout(function () {
363 | _this.$connect();
364 | _this.$reconnectAll();
365 | }, _this.settings.timeOut);
366 | };
367 |
368 | if (angular.isDefined(this.settings.headers)) {
369 | this.stompClient.connect(this.settings.headers, successCallback, errorCallback);
370 | } else {
371 | this.stompClient.connect(this.settings.login, this.settings.password, successCallback, errorCallback, this.settings.vhost);
372 | }
373 |
374 | return this.connectionState;
375 | }
376 | }, {
377 | key: 'subscribe',
378 | value: function subscribe(queue, callback, header, scope, json, digest) {
379 | if (header === undefined) header = {};
380 |
381 | var _this2 = this;
382 |
383 | if (json === undefined) json = false;
384 |
385 | this.connectionState.then(function () {
386 | return _this2.$stompSubscribe(queue, callback, header, scope, json, digest);
387 | }, function () {
388 | return _this2.$$addToConnectionQueue({ queue: queue, callback: callback, header: header, scope: scope, json: json, digest: digest });
389 | });
390 | return this;
391 | }
392 | }, {
393 | key: 'subscribeTo',
394 | value: function subscribeTo(topic) {
395 | return new SubscribeBuilder(this, topic);
396 | }
397 |
398 | /* Deprecated */
399 | }, {
400 | key: 'unsubscribe',
401 | value: function unsubscribe(url) {
402 | var _this3 = this;
403 |
404 | this.connectionState.then(function () {
405 | return _this3.$stompUnSubscribe(url);
406 | });
407 | return this;
408 | }
409 | }, {
410 | key: 'send',
411 | value: function send(queue, data) {
412 | var _this4 = this;
413 |
414 | var header = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];
415 |
416 | var sendDeffered = this.$q.defer();
417 |
418 | this.connectionState.then(function () {
419 | _this4.stompClient.send(queue, header, JSON.stringify(data));
420 | sendDeffered.resolve();
421 | });
422 |
423 | return sendDeffered.promise;
424 | }
425 | }, {
426 | key: 'disconnect',
427 | value: function disconnect() {
428 | var disconnectionPromise = this.$q.defer();
429 | this.stompClient.disconnect(function () {
430 | disconnectionPromise.resolve();
431 | });
432 |
433 | return disconnectionPromise.promise;
434 | }
435 | }, {
436 | key: '$stompSubscribe',
437 | value: function $stompSubscribe(queue, callback, header, scope, json, digest) {
438 | if (scope === undefined) scope = this.$rootScope;
439 |
440 | var sub = this.stompClient.subscribe(queue, function (message) {
441 | if (json) message.body = JSON.parse(message.body);
442 |
443 | if (digest) {
444 | scope.$applyAsync(function () {
445 | return callback(message);
446 | });
447 | } else {
448 | callback(message);
449 | }
450 | }, header);
451 |
452 | var connection = { queue: queue, sub: sub, callback: callback, header: header, scope: scope, json: json, digest: digest };
453 | this.$$addToConnectionQueue(connection);
454 | this.$unRegisterScopeOnDestroy(connection);
455 | }
456 | }, {
457 | key: '$stompUnSubscribe',
458 | value: function $stompUnSubscribe(queue) {
459 | this.connections.filter(function (c) {
460 | return c.queue === queue;
461 | }).forEach(function (c) {
462 | return c.sub.unsubscribe();
463 | });
464 |
465 | this.connections = this.connections.filter(function (c) {
466 | return c.queue != queue;
467 | });
468 | }
469 | }, {
470 | key: '$setConnection',
471 | value: function $setConnection() {
472 | this.stompClient = this.settings['class'] ? this.Stomp.over(new this.settings['class'](this.settings.url)) : this.Stomp.client(this.settings.url);
473 | this.stompClient.debug = this.settings.debug ? this.$log.debug : angular.noop;
474 | if (angular.isDefined(this.settings.heartbeat)) {
475 | this.stompClient.heartbeat.outgoing = this.settings.heartbeat.outgoing;
476 | this.stompClient.heartbeat.incoming = this.settings.heartbeat.incoming;
477 | }
478 | }
479 | }, {
480 | key: '$unRegisterScopeOnDestroy',
481 | value: function $unRegisterScopeOnDestroy(connection) {
482 | var _this5 = this;
483 |
484 | if (connection.scope !== undefined && angular.isFunction(connection.scope.$on)) connection.scope.$on('$destroy', function () {
485 | return _this5.$$unSubscribeOf(connection);
486 | });
487 | }
488 | }, {
489 | key: '$reconnectAll',
490 | value: function $reconnectAll() {
491 | var _this6 = this;
492 |
493 | var connections = this.connections;
494 | this.connections = [];
495 | // during subscription each connection will be added to this.connections array again
496 | connections.forEach(function (c) {
497 | return _this6.subscribe(c.queue, c.callback, c.header, c.scope, c.json, c.digest);
498 | });
499 | }
500 | }, {
501 | key: '$$unSubscribeOf',
502 | value: function $$unSubscribeOf(connection) {
503 | var _this7 = this;
504 |
505 | this.connections.filter(function (c) {
506 | return _this7.$$connectionEquality(c, connection);
507 | }).forEach(function (c) {
508 | return c.sub.unsubscribe();
509 | });
510 |
511 | this.connections = this.connections.filter(function (c) {
512 | return !_this7.$$connectionEquality(c, connection);
513 | });
514 | }
515 | }, {
516 | key: '$$addToConnectionQueue',
517 | value: function $$addToConnectionQueue(connection) {
518 | this.connections.push(connection);
519 | }
520 | }, {
521 | key: '$$connectionEquality',
522 | value: function $$connectionEquality(c1, c2) {
523 | return c1.queue === c2.queue && c1.callback === c2.callback && c1.header === c2.header && c1.scope === c2.scope && c1.digest === c2.digest;
524 | }
525 | }, {
526 | key: 'login',
527 | set: function set(login) {
528 | this.settings.login = login;
529 | }
530 | }, {
531 | key: 'password',
532 | set: function set(password) {
533 | this.settings.password = password;
534 | }
535 | }, {
536 | key: 'url',
537 | set: function set(url) {
538 | this.settings.url = url;
539 | }
540 | }]);
541 |
542 | return ngStompWebSocket;
543 | })();
544 |
545 | _export('default', ngStompWebSocket);
546 | }
547 | };
548 | });
549 | $__System.register("b", ["5", "6", "a"], function (_export) {
550 | var _createClass, _classCallCheck, ngStompWebSocket, ngstompProvider;
551 |
552 | return {
553 | setters: [function (_) {
554 | _createClass = _["default"];
555 | }, function (_2) {
556 | _classCallCheck = _2["default"];
557 | }, function (_a) {
558 | ngStompWebSocket = _a["default"];
559 | }],
560 | execute: function () {
561 | "use strict";
562 |
563 | ngstompProvider = (function () {
564 | function ngstompProvider() {
565 | _classCallCheck(this, ngstompProvider);
566 |
567 | this.settings = {
568 | timeOut: 5000,
569 | heartbeat: { outgoing: 10000, incoming: 10000 },
570 | autoConnect: true
571 | };
572 | }
573 |
574 | _createClass(ngstompProvider, [{
575 | key: "credential",
576 | value: function credential(login, password) {
577 | this.settings.login = login;
578 | this.settings.password = password;
579 | return this;
580 | }
581 | }, {
582 | key: "url",
583 | value: function url(_url) {
584 | this.settings.url = _url;
585 | return this;
586 | }
587 | }, {
588 | key: "class",
589 | value: function _class(clazz) {
590 | this.settings["class"] = clazz;
591 | return this;
592 | }
593 | }, {
594 | key: "setting",
595 | value: function setting(settingsObject) {
596 | this.settings = settingsObject;
597 | return this;
598 | }
599 | }, {
600 | key: "debug",
601 | value: function debug(boolean) {
602 | this.settings.debug = boolean;
603 | return this;
604 | }
605 | }, {
606 | key: "vhost",
607 | value: function vhost(host) {
608 | this.settings.vhost = host;
609 | return this;
610 | }
611 | }, {
612 | key: "reconnectAfter",
613 | value: function reconnectAfter(numberInSeconds) {
614 | this.settings.timeOut = numberInSeconds * 1000;
615 | return this;
616 | }
617 | }, {
618 | key: "heartbeat",
619 | value: function heartbeat(outgoing, incoming) {
620 | this.settings.heartbeat.outgoing = outgoing;
621 | this.settings.heartbeat.incoming = incoming;
622 | return this;
623 | }
624 | }, {
625 | key: "autoConnect",
626 | value: function autoConnect(autoConnectionDefaultValue) {
627 | this.settings.autoConnect = autoConnectionDefaultValue;
628 | return this;
629 | }
630 | }, {
631 | key: "headers",
632 | value: function headers(_headers) {
633 | this.settings.headers = _headers;
634 | return this;
635 | }
636 | }, {
637 | key: "$get",
638 | value: ["$q", "$log", "$rootScope", "$timeout", "Stomp", function $get($q, $log, $rootScope, $timeout, Stomp) {
639 | "ngInject";
640 | return new ngStompWebSocket(this.settings, $q, $log, $rootScope, $timeout, Stomp);
641 | }]
642 | }]);
643 |
644 | return ngstompProvider;
645 | })();
646 |
647 | _export("default", ngstompProvider);
648 | }
649 | };
650 | });
651 | $__System.register('1', ['9', 'c', 'b'], function (_export) {
652 | 'use strict';
653 |
654 | var angular, Stomp, ngstompProvider;
655 | return {
656 | setters: [function (_) {
657 | angular = _['default'];
658 | }, function (_c) {
659 | Stomp = _c['default'];
660 | }, function (_b) {
661 | ngstompProvider = _b['default'];
662 | }],
663 | execute: function () {
664 | _export('default', angular.module('AngularStompDK', []).provider('ngstomp', ngstompProvider).constant('Stomp', Stomp));
665 | }
666 | };
667 | });
668 | })
669 | (function(factory) {
670 | factory(angular, Stomp);
671 | });
672 | //# sourceMappingURL=angular-stomp.js.map
--------------------------------------------------------------------------------
/dist/angular-stomp.min.js:
--------------------------------------------------------------------------------
1 | "format global";"globals.angular angular";"globals.Stomp stompjs";!function(e){function t(e,t,s){return 4===arguments.length?n.apply(this,arguments):void i(e,{declarative:!0,deps:t,declare:s})}function n(e,t,n,s){i(e,{declarative:!1,deps:t,executingRequire:n,execute:s})}function i(e,t){t.name=e,e in h||(h[e]=t),t.normalizedDeps=t.deps}function s(e,t){if(t[e.groupIndex]=t[e.groupIndex]||[],-1==p.call(t[e.groupIndex],e)){t[e.groupIndex].push(e);for(var n=0,i=e.normalizedDeps.length;i>n;n++){var r=e.normalizedDeps[n],o=h[r];if(o&&!o.evaluated){var u=e.groupIndex+(o.declarative!=e.declarative);if(void 0===o.groupIndex||o.groupIndex=0;r--){for(var o=n[r],c=0;cr;r++){var u=n.importers[r];if(!u.locked)for(var c=0;cr;r++){var a,f=t.normalizedDeps[r],l=h[f],p=y[f];p?a=p.exports:l&&!l.declarative?a=l.esModule:l?(u(l),p=l.module,a=p.exports):a=d(f),p&&p.importers?(p.importers.push(n),n.dependencies.push(p)):n.dependencies.push(null),n.setters[r]&&n.setters[r](a)}}}function c(e){var t,n=h[e];if(n)n.declarative?l(e,[]):n.evaluated||a(n),t=n.module.exports;else if(t=d(e),!t)throw new Error("Unable to load dependency "+e+".");return(!n||n.declarative)&&t&&t.__useDefault?t["default"]:t}function a(t){if(!t.module){var n={},i=t.module={exports:n,id:t.name};if(!t.executingRequire)for(var s=0,r=t.normalizedDeps.length;r>s;s++){var o=t.normalizedDeps[s],u=h[o];u&&a(u)}t.evaluated=!0;var l=t.execute.call(e,function(e){for(var n=0,i=t.deps.length;i>n;n++)if(t.deps[n]==e)return c(t.normalizedDeps[n]);throw new TypeError("Module "+e+" not declared as a dependency.")},n,i);l&&(i.exports=l),n=i.exports,n&&n.__esModule?t.esModule=n:t.esModule=f(n)}}function f(t){if(t===e)return t;var n={};if("object"==typeof t||"function"==typeof t)if(v){var i;for(var s in t)(i=Object.getOwnPropertyDescriptor(t,s))&&b(n,s,i)}else{var r=t&&t.hasOwnProperty;for(var s in t)(!r||t.hasOwnProperty(s))&&(n[s]=t[s])}return n["default"]=t,b(n,"__useDefault",{value:!0}),n}function l(t,n){var i=h[t];if(i&&!i.evaluated&&i.declarative){n.push(t);for(var s=0,r=i.normalizedDeps.length;r>s;s++){var o=i.normalizedDeps[s];-1==p.call(n,o)&&(h[o]?l(o,n):d(o))}i.evaluated||(i.evaluated=!0,i.module.execute.call(e))}}function d(e){if($[e])return $[e];if("@node/"==e.substr(0,6))return m(e.substr(6));var t=h[e];if(!t)throw"Module "+e+" not present.";return r(e),l(e,[]),h[e]=void 0,t.declarative&&b(t.module.exports,"__esModule",{value:!0}),$[e]=t.declarative?t.module.exports:t.esModule}var h={},p=Array.prototype.indexOf||function(e){for(var t=0,n=this.length;n>t;t++)if(this[t]===e)return t;return-1},v=!0;try{Object.getOwnPropertyDescriptor({a:0},"a")}catch(g){v=!1}var b;!function(){try{Object.defineProperty({},"a",{})&&(b=Object.defineProperty)}catch(e){b=function(e,t,n){try{e[t]=n.value||n.get.call(e)}catch(i){}}}}();var y={},m="undefined"!=typeof System&&System._nodeRequire||"undefined"!=typeof require&&require.resolve&&"undefined"!=typeof process&&require,$={"@empty":{}};return function(e,i,s){return function(r){r(function(r){for(var o={_nodeRequire:m,register:t,registerDynamic:n,get:d,set:function(e,t){$[e]=t},newModule:function(e){return e}},u=0;u1)for(var u=1;u=0&&e.$timeout(function(){e.$connect(),e.$reconnectAll()},e.settings.timeOut)};return s.isDefined(this.settings.headers)?this.stompClient.connect(this.settings.headers,t,n):this.stompClient.connect(this.settings.login,this.settings.password,t,n,this.settings.vhost),this.connectionState}},{key:"subscribe",value:function(e,t,n,i,s,r){void 0===n&&(n={});var o=this;return void 0===s&&(s=!1),this.connectionState.then(function(){return o.$stompSubscribe(e,t,n,i,s,r)},function(){return o.$$addToConnectionQueue({queue:e,callback:t,header:n,scope:i,json:s,digest:r})}),this}},{key:"subscribeTo",value:function(e){return new i(this,e)}},{key:"unsubscribe",value:function(e){var t=this;return this.connectionState.then(function(){return t.$stompUnSubscribe(e)}),this}},{key:"send",value:function(e,t){var n=this,i=arguments.length<=2||void 0===arguments[2]?{}:arguments[2],s=this.$q.defer();return this.connectionState.then(function(){n.stompClient.send(e,i,JSON.stringify(t)),s.resolve()}),s.promise}},{key:"disconnect",value:function(){var e=this.$q.defer();return this.stompClient.disconnect(function(){e.resolve()}),e.promise}},{key:"$stompSubscribe",value:function(e,t,n,i,s,r){void 0===i&&(i=this.$rootScope);var o=this.stompClient.subscribe(e,function(e){s&&(e.body=JSON.parse(e.body)),r?i.$applyAsync(function(){return t(e)}):t(e)},n),u={queue:e,sub:o,callback:t,header:n,scope:i,json:s,digest:r};this.$$addToConnectionQueue(u),this.$unRegisterScopeOnDestroy(u)}},{key:"$stompUnSubscribe",value:function(e){this.connections.filter(function(t){return t.queue===e}).forEach(function(e){return e.sub.unsubscribe()}),this.connections=this.connections.filter(function(t){return t.queue!=e})}},{key:"$setConnection",value:function(){this.stompClient=this.settings["class"]?this.Stomp.over(new this.settings["class"](this.settings.url)):this.Stomp.client(this.settings.url),this.stompClient.debug=this.settings.debug?this.$log.debug:s.noop,s.isDefined(this.settings.heartbeat)&&(this.stompClient.heartbeat.outgoing=this.settings.heartbeat.outgoing,this.stompClient.heartbeat.incoming=this.settings.heartbeat.incoming)}},{key:"$unRegisterScopeOnDestroy",value:function(e){var t=this;void 0!==e.scope&&s.isFunction(e.scope.$on)&&e.scope.$on("$destroy",function(){return t.$$unSubscribeOf(e)})}},{key:"$reconnectAll",value:function(){var e=this,t=this.connections;this.connections=[],t.forEach(function(t){return e.subscribe(t.queue,t.callback,t.header,t.scope,t.json,t.digest)})}},{key:"$$unSubscribeOf",value:function(e){var t=this;this.connections.filter(function(n){return t.$$connectionEquality(n,e)}).forEach(function(e){return e.sub.unsubscribe()}),this.connections=this.connections.filter(function(n){return!t.$$connectionEquality(n,e)})}},{key:"$$addToConnectionQueue",value:function(e){this.connections.push(e)}},{key:"$$connectionEquality",value:function(e,t){return e.queue===t.queue&&e.callback===t.callback&&e.header===t.header&&e.scope===t.scope&&e.digest===t.digest}},{key:"login",set:function(e){this.settings.login=e}},{key:"password",set:function(e){this.settings.password=e}},{key:"url",set:function(e){this.settings.url=e}}]),e}(),e("default",r)}}}),e.register("b",["5","6","a"],function(e){var t,n,i,s;return{setters:[function(e){t=e["default"]},function(e){n=e["default"]},function(e){i=e["default"]}],execute:function(){"use strict";s=function(){function e(){n(this,e),this.settings={timeOut:5e3,heartbeat:{outgoing:1e4,incoming:1e4},autoConnect:!0}}return t(e,[{key:"credential",value:function(e,t){return this.settings.login=e,this.settings.password=t,this}},{key:"url",value:function(e){return this.settings.url=e,this}},{key:"class",value:function(e){return this.settings["class"]=e,this}},{key:"setting",value:function(e){return this.settings=e,this}},{key:"debug",value:function(e){return this.settings.debug=e,this}},{key:"vhost",value:function(e){return this.settings.vhost=e,this}},{key:"reconnectAfter",value:function(e){return this.settings.timeOut=1e3*e,this}},{key:"heartbeat",value:function(e,t){return this.settings.heartbeat.outgoing=e,this.settings.heartbeat.incoming=t,this}},{key:"autoConnect",value:function(e){return this.settings.autoConnect=e,this}},{key:"headers",value:function(e){return this.settings.headers=e,this}},{key:"$get",value:["$q","$log","$rootScope","$timeout","Stomp",function(e,t,n,s,r){"ngInject";return new i(this.settings,e,t,n,s,r)}]}]),e}(),e("default",s)}}}),e.register("1",["9","c","b"],function(e){"use strict";var t,n,i;return{setters:[function(e){t=e["default"]},function(e){n=e["default"]},function(e){i=e["default"]}],execute:function(){e("default",t.module("AngularStompDK",[]).provider("ngstomp",i).constant("Stomp",n))}}})})(function(e){e(angular,Stomp)});
2 | //# sourceMappingURL=angular-stomp.min.js.map
3 |
--------------------------------------------------------------------------------
/dist/angular-stomp.min.js.map:
--------------------------------------------------------------------------------
1 | {"version":3,"sources":["angular-stomp.js","../jspm_packages/npm/core-js@1.2.6/library/modules/$.js","../jspm_packages/npm/core-js@1.2.6/library/fn/object/define-property.js","../jspm_packages/npm/babel-runtime@5.8.34/core-js/object/define-property.js","../jspm_packages/npm/babel-runtime@5.8.34/helpers/create-class.js","../jspm_packages/npm/babel-runtime@5.8.34/helpers/class-call-check.js","../core/unSubscriber.js","../core/builder.js","../core/service.js","../core/provider.js","../core/ngStomp.js"],"names":["e","r","o","arguments","length","t","apply","this","n","declarative","deps","declare","executingRequire","execute","name","p","normalizedDeps","groupIndex","v","call","push","a","u","evaluated","d","splice","TypeError","i","s","l","x","dependencies","exports","importers","module","locked","setters","c","esModule","f","Error","__useDefault","id","__esModule","g","Object","getOwnPropertyDescriptor","h","hasOwnProperty","value","D","substr","y","Array","prototype","indexOf","m","defineProperty","get","System","_nodeRequire","require","resolve","process","@empty","register","registerDynamic","set","newModule","self","global","$__System","window","document","location","protocol","hostname","port","getPathVars","lastIndexOf","split","pop","join","isWindows","filename","dirname","$__require","__define","define","undefined","$Object","create","getProto","getPrototypeOf","isEnum","propertyIsEnumerable","getDesc","setDesc","setDescs","defineProperties","getKeys","keys","getNames","getOwnPropertyNames","getSymbols","getOwnPropertySymbols","each","forEach","$","it","key","desc","default","_Object$defineProperty","target","props","descriptor","enumerable","configurable","writable","Constructor","protoProps","staticProps","instance","_export","_createClass","_classCallCheck","Unsubscriber","_","_2","ngStomp","connections","_this","$$unSubscribeOf","queue","_this2","filter","index","_this3","callback","header","headers","scope","digest","UnSubscriber","angular","SubscribeBuilder","_3","_4","subscribeTo","aCallback","aScope","json","connect","noop","and","subscribe","ngStompWebSocket","settings","$q","$log","$rootScope","$timeout","Stomp","$initConnectionState","autoConnect","$connect","deferred","reject","defer","connectionState","promise","$setConnection","successCallback","errorCallback","timeOut","$reconnectAll","isDefined","stompClient","login","password","vhost","then","$stompSubscribe","$$addToConnectionQueue","topic","url","$stompUnSubscribe","data","_this4","sendDeffered","send","JSON","stringify","disconnectionPromise","disconnect","sub","message","body","parse","$applyAsync","connection","$unRegisterScopeOnDestroy","unsubscribe","over","client","debug","heartbeat","outgoing","incoming","_this5","isFunction","$on","_this6","_this7","$$connectionEquality","c1","c2","ngstompProvider","_a","_url","clazz","settingsObject","boolean","host","numberInSeconds","autoConnectionDefaultValue","_headers","_c","_b","provider","constant","factory"],"mappings":"AAAA,eACA,0BACA,0BAEC,SAASA,GAAG,QAASC,GAAED,EAAEC,EAAEC,GAAG,MAAO,KAAIC,UAAUC,OAAOC,EAAE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,SAAUoG,GACTjE,EAAQiE,EAAG,YACZ,SAAUC,GACTX,EAAkBW,EAAG,aAEzBxN,QAAS,WACL+G,EAAQ,UUnpBLqB,EACV/G,OAAO,qBACPoM,SAAS,UAAWZ,GACpBa,SAAS,QAASpE,UVqpBtB,SAASqE,GACRA,EAAQvF,QAASkB","file":"angular-stomp.min.js","sourcesContent":["\"format global\";\n\"globals.angular angular\";\n\"globals.Stomp stompjs\";\n\n!function(e){function r(e,r,o){return 4===arguments.length?t.apply(this,arguments):void n(e,{declarative:!0,deps:r,declare:o})}function t(e,r,t,o){n(e,{declarative:!1,deps:r,executingRequire:t,execute:o})}function n(e,r){r.name=e,e in p||(p[e]=r),r.normalizedDeps=r.deps}function o(e,r){if(r[e.groupIndex]=r[e.groupIndex]||[],-1==v.call(r[e.groupIndex],e)){r[e.groupIndex].push(e);for(var t=0,n=e.normalizedDeps.length;n>t;t++){var a=e.normalizedDeps[t],u=p[a];if(u&&!u.evaluated){var d=e.groupIndex+(u.declarative!=e.declarative);if(void 0===u.groupIndex||u.groupIndex=0;a--){for(var u=t[a],i=0;ia;a++){var d=t.importers[a];if(!d.locked)for(var i=0;ia;a++){var l,s=r.normalizedDeps[a],c=p[s],v=x[s];v?l=v.exports:c&&!c.declarative?l=c.esModule:c?(d(c),v=c.module,l=v.exports):l=f(s),v&&v.importers?(v.importers.push(t),t.dependencies.push(v)):t.dependencies.push(null),t.setters[a]&&t.setters[a](l)}}}function i(e){var r,t=p[e];if(t)t.declarative?c(e,[]):t.evaluated||l(t),r=t.module.exports;else if(r=f(e),!r)throw new Error(\"Unable to load dependency \"+e+\".\");return(!t||t.declarative)&&r&&r.__useDefault?r[\"default\"]:r}function l(r){if(!r.module){var t={},n=r.module={exports:t,id:r.name};if(!r.executingRequire)for(var o=0,a=r.normalizedDeps.length;a>o;o++){var u=r.normalizedDeps[o],d=p[u];d&&l(d)}r.evaluated=!0;var c=r.execute.call(e,function(e){for(var t=0,n=r.deps.length;n>t;t++)if(r.deps[t]==e)return i(r.normalizedDeps[t]);throw new TypeError(\"Module \"+e+\" not declared as a dependency.\")},t,n);c&&(n.exports=c),t=n.exports,t&&t.__esModule?r.esModule=t:r.esModule=s(t)}}function s(r){if(r===e)return r;var t={};if(\"object\"==typeof r||\"function\"==typeof r)if(g){var n;for(var o in r)(n=Object.getOwnPropertyDescriptor(r,o))&&h(t,o,n)}else{var a=r&&r.hasOwnProperty;for(var o in r)(!a||r.hasOwnProperty(o))&&(t[o]=r[o])}return t[\"default\"]=r,h(t,\"__useDefault\",{value:!0}),t}function c(r,t){var n=p[r];if(n&&!n.evaluated&&n.declarative){t.push(r);for(var o=0,a=n.normalizedDeps.length;a>o;o++){var u=n.normalizedDeps[o];-1==v.call(t,u)&&(p[u]?c(u,t):f(u))}n.evaluated||(n.evaluated=!0,n.module.execute.call(e))}}function f(e){if(D[e])return D[e];if(\"@node/\"==e.substr(0,6))return y(e.substr(6));var r=p[e];if(!r)throw\"Module \"+e+\" not present.\";return a(e),c(e,[]),p[e]=void 0,r.declarative&&h(r.module.exports,\"__esModule\",{value:!0}),D[e]=r.declarative?r.module.exports:r.esModule}var p={},v=Array.prototype.indexOf||function(e){for(var r=0,t=this.length;t>r;r++)if(this[r]===e)return r;return-1},g=!0;try{Object.getOwnPropertyDescriptor({a:0},\"a\")}catch(m){g=!1}var h;!function(){try{Object.defineProperty({},\"a\",{})&&(h=Object.defineProperty)}catch(e){h=function(e,r,t){try{e[r]=t.value||t.get.call(e)}catch(n){}}}}();var x={},y=\"undefined\"!=typeof System&&System._nodeRequire||\"undefined\"!=typeof require&&require.resolve&&\"undefined\"!=typeof process&&require,D={\"@empty\":{}};return function(e,n,o){return function(a){a(function(a){for(var u={_nodeRequire:y,register:r,registerDynamic:t,get:f,set:function(e,r){D[e]=r},newModule:function(e){return e}},d=0;d1)for(var d=1;d= 0 && _this.$timeout(function () {\n _this.$connect();\n _this.$reconnectAll();\n }, _this.settings.timeOut);\n };\n\n if (angular.isDefined(this.settings.headers)) {\n this.stompClient.connect(this.settings.headers, successCallback, errorCallback);\n } else {\n this.stompClient.connect(this.settings.login, this.settings.password, successCallback, errorCallback, this.settings.vhost);\n }\n\n return this.connectionState;\n }\n }, {\n key: 'subscribe',\n value: function subscribe(queue, callback, header, scope, json, digest) {\n if (header === undefined) header = {};\n\n var _this2 = this;\n\n if (json === undefined) json = false;\n\n this.connectionState.then(function () {\n return _this2.$stompSubscribe(queue, callback, header, scope, json, digest);\n }, function () {\n return _this2.$$addToConnectionQueue({ queue: queue, callback: callback, header: header, scope: scope, json: json, digest: digest });\n });\n return this;\n }\n }, {\n key: 'subscribeTo',\n value: function subscribeTo(topic) {\n return new SubscribeBuilder(this, topic);\n }\n\n /* Deprecated */\n }, {\n key: 'unsubscribe',\n value: function unsubscribe(url) {\n var _this3 = this;\n\n this.connectionState.then(function () {\n return _this3.$stompUnSubscribe(url);\n });\n return this;\n }\n }, {\n key: 'send',\n value: function send(queue, data) {\n var _this4 = this;\n\n var header = arguments.length <= 2 || arguments[2] === undefined ? {} : arguments[2];\n\n var sendDeffered = this.$q.defer();\n\n this.connectionState.then(function () {\n _this4.stompClient.send(queue, header, JSON.stringify(data));\n sendDeffered.resolve();\n });\n\n return sendDeffered.promise;\n }\n }, {\n key: 'disconnect',\n value: function disconnect() {\n var disconnectionPromise = this.$q.defer();\n this.stompClient.disconnect(function () {\n disconnectionPromise.resolve();\n });\n\n return disconnectionPromise.promise;\n }\n }, {\n key: '$stompSubscribe',\n value: function $stompSubscribe(queue, callback, header, scope, json, digest) {\n if (scope === undefined) scope = this.$rootScope;\n\n var sub = this.stompClient.subscribe(queue, function (message) {\n if (json) message.body = JSON.parse(message.body);\n\n if (digest) {\n scope.$applyAsync(function () {\n return callback(message);\n });\n } else {\n callback(message);\n }\n }, header);\n\n var connection = { queue: queue, sub: sub, callback: callback, header: header, scope: scope, json: json, digest: digest };\n this.$$addToConnectionQueue(connection);\n this.$unRegisterScopeOnDestroy(connection);\n }\n }, {\n key: '$stompUnSubscribe',\n value: function $stompUnSubscribe(queue) {\n this.connections.filter(function (c) {\n return c.queue === queue;\n }).forEach(function (c) {\n return c.sub.unsubscribe();\n });\n\n this.connections = this.connections.filter(function (c) {\n return c.queue != queue;\n });\n }\n }, {\n key: '$setConnection',\n value: function $setConnection() {\n this.stompClient = this.settings['class'] ? this.Stomp.over(new this.settings['class'](this.settings.url)) : this.Stomp.client(this.settings.url);\n this.stompClient.debug = this.settings.debug ? this.$log.debug : angular.noop;\n if (angular.isDefined(this.settings.heartbeat)) {\n this.stompClient.heartbeat.outgoing = this.settings.heartbeat.outgoing;\n this.stompClient.heartbeat.incoming = this.settings.heartbeat.incoming;\n }\n }\n }, {\n key: '$unRegisterScopeOnDestroy',\n value: function $unRegisterScopeOnDestroy(connection) {\n var _this5 = this;\n\n if (connection.scope !== undefined && angular.isFunction(connection.scope.$on)) connection.scope.$on('$destroy', function () {\n return _this5.$$unSubscribeOf(connection);\n });\n }\n }, {\n key: '$reconnectAll',\n value: function $reconnectAll() {\n var _this6 = this;\n\n var connections = this.connections;\n this.connections = [];\n // during subscription each connection will be added to this.connections array again\n connections.forEach(function (c) {\n return _this6.subscribe(c.queue, c.callback, c.header, c.scope, c.json, c.digest);\n });\n }\n }, {\n key: '$$unSubscribeOf',\n value: function $$unSubscribeOf(connection) {\n var _this7 = this;\n\n this.connections.filter(function (c) {\n return _this7.$$connectionEquality(c, connection);\n }).forEach(function (c) {\n return c.sub.unsubscribe();\n });\n\n this.connections = this.connections.filter(function (c) {\n return !_this7.$$connectionEquality(c, connection);\n });\n }\n }, {\n key: '$$addToConnectionQueue',\n value: function $$addToConnectionQueue(connection) {\n this.connections.push(connection);\n }\n }, {\n key: '$$connectionEquality',\n value: function $$connectionEquality(c1, c2) {\n return c1.queue === c2.queue && c1.callback === c2.callback && c1.header === c2.header && c1.scope === c2.scope && c1.digest === c2.digest;\n }\n }, {\n key: 'login',\n set: function set(login) {\n this.settings.login = login;\n }\n }, {\n key: 'password',\n set: function set(password) {\n this.settings.password = password;\n }\n }, {\n key: 'url',\n set: function set(url) {\n this.settings.url = url;\n }\n }]);\n\n return ngStompWebSocket;\n })();\n\n _export('default', ngStompWebSocket);\n }\n };\n});\n$__System.register(\"b\", [\"5\", \"6\", \"a\"], function (_export) {\n var _createClass, _classCallCheck, ngStompWebSocket, ngstompProvider;\n\n return {\n setters: [function (_) {\n _createClass = _[\"default\"];\n }, function (_2) {\n _classCallCheck = _2[\"default\"];\n }, function (_a) {\n ngStompWebSocket = _a[\"default\"];\n }],\n execute: function () {\n \"use strict\";\n\n ngstompProvider = (function () {\n function ngstompProvider() {\n _classCallCheck(this, ngstompProvider);\n\n this.settings = {\n timeOut: 5000,\n heartbeat: { outgoing: 10000, incoming: 10000 },\n autoConnect: true\n };\n }\n\n _createClass(ngstompProvider, [{\n key: \"credential\",\n value: function credential(login, password) {\n this.settings.login = login;\n this.settings.password = password;\n return this;\n }\n }, {\n key: \"url\",\n value: function url(_url) {\n this.settings.url = _url;\n return this;\n }\n }, {\n key: \"class\",\n value: function _class(clazz) {\n this.settings[\"class\"] = clazz;\n return this;\n }\n }, {\n key: \"setting\",\n value: function setting(settingsObject) {\n this.settings = settingsObject;\n return this;\n }\n }, {\n key: \"debug\",\n value: function debug(boolean) {\n this.settings.debug = boolean;\n return this;\n }\n }, {\n key: \"vhost\",\n value: function vhost(host) {\n this.settings.vhost = host;\n return this;\n }\n }, {\n key: \"reconnectAfter\",\n value: function reconnectAfter(numberInSeconds) {\n this.settings.timeOut = numberInSeconds * 1000;\n return this;\n }\n }, {\n key: \"heartbeat\",\n value: function heartbeat(outgoing, incoming) {\n this.settings.heartbeat.outgoing = outgoing;\n this.settings.heartbeat.incoming = incoming;\n return this;\n }\n }, {\n key: \"autoConnect\",\n value: function autoConnect(autoConnectionDefaultValue) {\n this.settings.autoConnect = autoConnectionDefaultValue;\n return this;\n }\n }, {\n key: \"headers\",\n value: function headers(_headers) {\n this.settings.headers = _headers;\n return this;\n }\n }, {\n key: \"$get\",\n value: [\"$q\", \"$log\", \"$rootScope\", \"$timeout\", \"Stomp\", function $get($q, $log, $rootScope, $timeout, Stomp) {\n \"ngInject\";\n return new ngStompWebSocket(this.settings, $q, $log, $rootScope, $timeout, Stomp);\n }]\n }]);\n\n return ngstompProvider;\n })();\n\n _export(\"default\", ngstompProvider);\n }\n };\n});\n$__System.register('1', ['9', 'c', 'b'], function (_export) {\n 'use strict';\n\n var angular, Stomp, ngstompProvider;\n return {\n setters: [function (_) {\n angular = _['default'];\n }, function (_c) {\n Stomp = _c['default'];\n }, function (_b) {\n ngstompProvider = _b['default'];\n }],\n execute: function () {\n _export('default', angular.module('AngularStompDK', []).provider('ngstomp', ngstompProvider).constant('Stomp', Stomp));\n }\n };\n});\n})\n(function(factory) {\n factory(angular, Stomp);\n});\n","/* */ \nvar $Object = Object;\nmodule.exports = {\n create: $Object.create,\n getProto: $Object.getPrototypeOf,\n isEnum: {}.propertyIsEnumerable,\n getDesc: $Object.getOwnPropertyDescriptor,\n setDesc: $Object.defineProperty,\n setDescs: $Object.defineProperties,\n getKeys: $Object.keys,\n getNames: $Object.getOwnPropertyNames,\n getSymbols: $Object.getOwnPropertySymbols,\n each: [].forEach\n};","/* */ \nvar $ = require('../../modules/$');\nmodule.exports = function defineProperty(it, key, desc) {\n return $.setDesc(it, key, desc);\n};\n","/* */ \nmodule.exports = { \"default\": require(\"core-js/library/fn/object/define-property\"), __esModule: true };","/* */ \n\"use strict\";\nvar _Object$defineProperty = require('../core-js/object/define-property')[\"default\"];\nexports[\"default\"] = (function() {\n function defineProperties(target, props) {\n for (var i = 0; i < props.length; i++) {\n var descriptor = props[i];\n descriptor.enumerable = descriptor.enumerable || false;\n descriptor.configurable = true;\n if (\"value\" in descriptor)\n descriptor.writable = true;\n _Object$defineProperty(target, descriptor.key, descriptor);\n }\n }\n return function(Constructor, protoProps, staticProps) {\n if (protoProps)\n defineProperties(Constructor.prototype, protoProps);\n if (staticProps)\n defineProperties(Constructor, staticProps);\n return Constructor;\n };\n})();\nexports.__esModule = true;\n","/* */ \n\"use strict\";\n\nexports[\"default\"] = function (instance, Constructor) {\n if (!(instance instanceof Constructor)) {\n throw new TypeError(\"Cannot call a class as a function\");\n }\n};\n\nexports.__esModule = true;","/**\n * Created by kevin on 10/01/2016.\n */\n\nexport default class Unsubscriber {\n\n constructor(ngStomp, connections) {\n this.ngStomp = ngStomp;\n this.connections = connections;\n }\n\n unSubscribeAll() {\n this.connections.forEach(c => this.$$unSubscribeOf(c));\n this.connections = [];\n }\n\n unSubscribeOf(queue) {\n this.connections\n .filter(c => c.queue === queue)\n .forEach(c => this.$$unSubscribeOf(c));\n\n this.connections = this.connections.filter(c => c.queue !== queue);\n }\n\n unSubscribeNth(index) {\n this.connections\n .filter(c => c.index === index)\n .forEach(c => this.$$unSubscribeOf(c));\n\n this.connections = this.connections.filter(c => c.index !== index);\n }\n\n $$unSubscribeOf(c) {\n this.ngStomp.$$unSubscribeOf({ queue: c.queue, callback: c.callback, header: c.headers, scope: c.scope, digest : c.digest});\n }\n\n}","/**\n * Created by kevin on 14/12/2015.\n */\nimport UnSubscriber from './unSubscriber';\nimport angular from 'angular';\n\nexport default class SubscribeBuilder {\n\n /*@ngNoInject*/\n constructor(ngStomp, queue) {\n this.ngStomp = ngStomp;\n this.connections = [];\n\n this.subscribeTo(queue);\n }\n\n callback(aCallback) {\n this.aCallback = aCallback;\n return this;\n }\n\n withHeaders(headers) {\n this.headers = headers;\n return this;\n }\n\n bindTo(aScope) {\n this.scope = aScope;\n return this;\n }\n\n withBodyInJson() {\n this.json = true;\n return this;\n }\n\n withDigest(digest) {\n this.digest = digest;\n return this;\n }\n\n build() {\n return this.connect();\n }\n\n subscribeTo(queue) {\n this.queue = queue;\n this.aCallback = angular.noop;\n this.headers = {};\n this.scope = undefined;\n this.json = false;\n this.digest = true;\n\n return this;\n }\n\n connect() {\n this.and();\n this.connections.forEach(c => this.ngStomp.subscribe(c.queue, c.callback, c.headers, c.scope, c.json, c.digest));\n return new UnSubscriber(this.ngStomp, this.connections);\n }\n\n and() {\n this.connections.push({\n queue : this.queue, \n callback : this.aCallback, \n headers : this.headers, \n scope : this.scope, \n json : this.json,\n digest : this.digest,\n index : this.connections.length\n });\n return this;\n }\n}","/**\n * Created by kevin on 14/12/2015.\n */\nimport SubscribeBuilder from './builder';\nimport angular from 'angular';\n\nexport default class ngStompWebSocket {\n\n /*@ngNoInject*/\n constructor(settings, $q, $log, $rootScope, $timeout, Stomp) {\n this.settings = settings;\n this.$q = $q;\n this.$rootScope = $rootScope;\n this.$log = $log;\n this.Stomp = Stomp;\n this.$timeout = $timeout;\n this.connections = [];\n\n this.$initConnectionState();\n if (settings.autoConnect) {\n this.connect();\n }\n }\n\n connect() {\n this.$initConnectionState();\n return this.$connect();\n }\n\n $initConnectionState() {\n this.deferred && this.deferred.reject();\n this.deferred = this.$q.defer();\n this.connectionState = this.deferred.promise;\n }\n\n $connect() {\n this.$setConnection();\n\n let successCallback = () => this.deferred.resolve();\n let errorCallback = () => {\n this.deferred.reject();\n this.$initConnectionState();\n this.settings.timeOut >= 0 && this.$timeout(() => {\n this.$connect();\n this.$reconnectAll();\n }, this.settings.timeOut);\n };\n\n if (angular.isDefined(this.settings.headers)) {\n this.stompClient.connect(\n this.settings.headers,\n successCallback,\n errorCallback\n )\n } else {\n this.stompClient.connect(\n this.settings.login,\n this.settings.password,\n successCallback,\n errorCallback,\n this.settings.vhost\n );\n }\n\n\n return this.connectionState;\n }\n\n subscribe(queue, callback, header = {}, scope, json = false, digest) {\n this.connectionState\n .then(\n () => this.$stompSubscribe(queue, callback, header, scope, json, digest),\n () => this.$$addToConnectionQueue({ queue, callback, header, scope, json, digest })\n )\n ;\n return this;\n }\n\n subscribeTo(topic) {\n return new SubscribeBuilder(this, topic);\n }\n\n /* Deprecated */\n unsubscribe(url) {\n this.connectionState.then(() => this.$stompUnSubscribe(url));\n return this;\n }\n\n send(queue, data, header = {}) {\n let sendDeffered = this.$q.defer();\n\n this.connectionState.then(() => {\n this.stompClient.send(queue, header, JSON.stringify(data));\n sendDeffered.resolve();\n });\n\n return sendDeffered.promise;\n }\n\n disconnect() {\n let disconnectionPromise = this.$q.defer();\n this.stompClient.disconnect(() => {\n disconnectionPromise.resolve();\n });\n\n return disconnectionPromise.promise;\n }\n\n set login(login) {\n this.settings.login = login;\n }\n\n set password(password) {\n this.settings.password = password;\n }\n\n set url(url) {\n this.settings.url = url;\n }\n\n $stompSubscribe(queue, callback, header, scope = this.$rootScope, json, digest) {\n let sub = this.stompClient.subscribe(queue, message => {\n if (json) message.body = JSON.parse(message.body);\n\n if (digest) {\n scope.$applyAsync(() => callback(message));\n } else {\n callback(message);\n }\n }, header);\n\n let connection = { queue, sub, callback, header, scope, json, digest};\n this.$$addToConnectionQueue(connection);\n this.$unRegisterScopeOnDestroy(connection);\n }\n\n $stompUnSubscribe(queue) {\n this.connections\n .filter(c => c.queue === queue)\n .forEach(c => c.sub.unsubscribe());\n\n this.connections = this.connections.filter(c => c.queue != queue);\n }\n\n $setConnection() {\n this.stompClient = this.settings.class ? this.Stomp.over(new this.settings.class(this.settings.url)) : this.Stomp.client(this.settings.url);\n this.stompClient.debug = (this.settings.debug) ? this.$log.debug : angular.noop;\n if (angular.isDefined(this.settings.heartbeat)) {\n this.stompClient.heartbeat.outgoing = this.settings.heartbeat.outgoing;\n this.stompClient.heartbeat.incoming = this.settings.heartbeat.incoming;\n }\n }\n\n $unRegisterScopeOnDestroy(connection) {\n if (connection.scope !== undefined && angular.isFunction(connection.scope.$on))\n connection.scope.$on('$destroy', () => this.$$unSubscribeOf(connection) );\n }\n\n $reconnectAll() {\n let connections = this.connections;\n this.connections = [];\n // during subscription each connection will be added to this.connections array again\n connections.forEach(c => this.subscribe(c.queue, c.callback, c.header, c.scope, c.json, c.digest));\n }\n\n $$unSubscribeOf(connection) {\n this.connections\n .filter(c => this.$$connectionEquality(c, connection))\n .forEach(c => c.sub.unsubscribe());\n\n this.connections = this.connections.filter(c => !this.$$connectionEquality(c, connection));\n }\n\n $$addToConnectionQueue(connection) {\n this.connections.push(connection);\n }\n\n $$connectionEquality(c1, c2) {\n return c1.queue === c2.queue\n && c1.callback === c2.callback\n && c1.header === c2.header\n && c1.scope === c2.scope\n && c1.digest === c2.digest;\n }\n}","import ngStompWebSocket from './service';\n\nexport default class ngstompProvider {\n\n settings = {\n timeOut : 5000,\n heartbeat : { outgoing: 10000, incoming: 10000},\n autoConnect : true\n };\n\n constructor() {}\n\n credential(login, password) {\n this.settings.login = login;\n this.settings.password = password;\n return this;\n }\n\n url(url) {\n this.settings.url = url;\n return this;\n }\n\n class(clazz) {\n this.settings.class = clazz;\n return this;\n }\n\n setting(settingsObject) {\n this.settings = settingsObject;\n return this;\n }\n\n debug(boolean) {\n this.settings.debug = boolean;\n return this;\n }\n\n vhost(host) {\n this.settings.vhost = host;\n return this;\n }\n\n reconnectAfter(numberInSeconds) {\n this.settings.timeOut = numberInSeconds * 1000;\n return this;\n }\n\n heartbeat(outgoing, incoming) {\n this.settings.heartbeat.outgoing = outgoing;\n this.settings.heartbeat.incoming = incoming;\n return this;\n }\n\n autoConnect(autoConnectionDefaultValue) {\n this.settings.autoConnect = autoConnectionDefaultValue;\n return this;\n }\n\n headers(headers) {\n this.settings.headers = headers;\n return this;\n }\n\n $get($q, $log, $rootScope, $timeout, Stomp) {\n \"ngInject\";\n return new ngStompWebSocket(this.settings, $q, $log, $rootScope, $timeout, Stomp);\n }\n}\n\n\n","import angular from 'angular';\nimport Stomp from 'stompjs';\nimport ngstompProvider from './provider';\n\nexport default angular\n .module('AngularStompDK', [])\n .provider('ngstomp', ngstompProvider)\n .constant('Stomp', Stomp);"],"sourceRoot":"/source/"}
--------------------------------------------------------------------------------
/gulpfile.babel.js:
--------------------------------------------------------------------------------
1 | /* Full config of gulp task located in ./build/tasks/*.js */
2 |
3 | import requiredir from 'require-dir';
4 |
5 | requiredir('./build/tasks', { recurse: true });
--------------------------------------------------------------------------------
/index.js:
--------------------------------------------------------------------------------
1 | require('./dist/angular-stomp.min');
2 | module.exports = 'AngularStompDK';
3 |
--------------------------------------------------------------------------------
/karma.conf.js:
--------------------------------------------------------------------------------
1 | module.exports = function (config) {
2 | config.set({
3 | frameworks: ['jspm', 'jasmine', 'jasmine-matchers'],
4 |
5 | files: [
6 | 'node_modules/karma-babel-preprocessor/node_modules/babel-core/browser-polyfill.js'
7 | ],
8 |
9 | preprocessors: {
10 | 'core/**/!(*.spec).js': ['babel', 'coverage']
11 | },
12 |
13 | babelPreprocessor: { options: { stage: 0, sourceMap: 'inline' } },
14 |
15 | /*basePath: 'core',*/
16 |
17 | jspm: {
18 | config: 'config.js',
19 | loadFiles: ['core/**/*.spec.js'],
20 | serveFiles: ['core/**/*.+(js|html|css)', 'mock/**/*.+(js|html|css)'],
21 | stripExtension: true
22 | },
23 |
24 | proxies: {
25 | '/core/' : '/base/core/',
26 | '/mock/' : '/base/mock/',
27 | '/jspm_packages/': '/base/jspm_packages/'
28 | },
29 |
30 | reporters: ['dots', 'coverage'],
31 |
32 | coverageReporter: {
33 | instrumenters: { isparta : require('isparta') },
34 | instrumenter: { 'core/**/*.js': 'isparta' },
35 | dir: 'reports/coverage/',
36 | subdir: normalizationBrowserName,
37 | reporters: [
38 | {type: 'html'}, {type: 'json'}, {type: 'lcov'}, {type: 'text-summary'}
39 | ]
40 | },
41 |
42 | /*logLevel: config.LOG_DEBUG,*/
43 | browsers: ['PhantomJS'],
44 | singleRun : false,
45 | browserNoActivityTimeout: 75000
46 | });
47 |
48 | function normalizationBrowserName(browser) {
49 | return browser.toLowerCase().split(/[ /-]/)[0];
50 | }
51 | };
--------------------------------------------------------------------------------
/mock/ngStomp.js:
--------------------------------------------------------------------------------
1 | /**
2 | * Created by kevin on 12/01/2016.
3 | */
4 |
5 | export default class NgStomp {
6 |
7 | constructor() {
8 | this.spies = {
9 | $$unSubscribeOf : spyOn(this, '$$unSubscribeOf').and.callThrough()
10 | }
11 | }
12 |
13 | $$unSubscribeOf(){}
14 | }
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "AngularStompDK",
3 | "version": "0.11.0",
4 | "description": "Angular Stomp DK",
5 | "jspm": {
6 | "dependencies": {
7 | "angular": "github:angular/bower-angular@^1.4.7",
8 | "angular-mocks": "github:angular/bower-angular-mocks@^1.4.7",
9 | "stompjs": "github:jmesnil/stomp-websocket@^2.3.4"
10 | },
11 | "devDependencies": {
12 | "babel": "npm:babel-core@^5.8.24",
13 | "babel-runtime": "npm:babel-runtime@^5.8.24",
14 | "core-js": "npm:core-js@^1.1.4"
15 | }
16 | },
17 | "devDependencies": {
18 | "babel": "^5.8.24",
19 | "del": "^2.2.0",
20 | "gulp": "^3.9.0",
21 | "gulp-bump": "^1.0.0",
22 | "gulp-conventional-changelog": "^0.7.0",
23 | "gulp-coveralls": "^0.1.4",
24 | "gulp-eslint": "^1.0.0",
25 | "gulp-git": "^1.6.0",
26 | "gulp-gzip": "^1.2.0",
27 | "gulp-ng-annotate": "^1.1.0",
28 | "gulp-rename": "^1.2.2",
29 | "gulp-sourcemaps": "^1.6.0",
30 | "gulp-uglify": "^1.4.2",
31 | "gulp-util": "^3.0.7",
32 | "isparta": "^3.1.0",
33 | "istanbul": "gotwarlost/istanbul.git#source-map",
34 | "jasmine-core": "^2.3.4",
35 | "jasmine-expect": "^2.0.0-beta2",
36 | "jasmine-reporters": "^2.0.7",
37 | "jspm": "0.16.25",
38 | "karma": "^0.13.11",
39 | "karma-babel-preprocessor": "^5.2.2",
40 | "karma-coverage": "douglasduteil/karma-coverage#next",
41 | "karma-jasmine": "^0.3.6",
42 | "karma-jasmine-matchers": "^2.0.0-beta2",
43 | "karma-jspm": "^2.0.1",
44 | "karma-phantomjs-launcher": "^0.2.1",
45 | "mkdirp": "^0.5.1",
46 | "phantomjs": "^1.9.18",
47 | "require-dir": "^0.3.0",
48 | "run-sequence": "^1.1.4",
49 | "semver": "^5.0.3"
50 | },
51 | "scripts": {
52 | "pretest": "npm run build",
53 | "prebuild": "jspm install",
54 | "build": "gulp build",
55 | "release": "gulp release --type $(type)",
56 | "postrelease": "npm publish",
57 | "test": "karma start --single-run",
58 | "test-tdd": "karma start"
59 | },
60 | "repository": {
61 | "type": "git",
62 | "url": "https://github.com/davinkevin/AngularStompDK.git"
63 | },
64 | "author": "Davin Kevin",
65 | "license": "ISC",
66 | "bugs": {
67 | "url": "https://github.com/davinkevin/AngularStomp/issues"
68 | },
69 | "main": "index.js",
70 | "homepage": "http://davinkevin.github.io/AngularStompDK/"
71 | }
72 |
--------------------------------------------------------------------------------