blob: bf04b86e0a6cb49835be5b41b6fbc6f572d1e5e3 [file] [log] [blame]
Simon Hunt1e4a0012015-01-21 11:36:08 -08001/*
2 * Copyright 2015 Open Networking Laboratory
3 *
4 * Licensed under the Apache License, Version 2.0 (the "License");
5 * you may not use this file except in compliance with the License.
6 * You may obtain a copy of the License at
7 *
8 * http://www.apache.org/licenses/LICENSE-2.0
9 *
10 * Unless required by applicable law or agreed to in writing, software
11 * distributed under the License is distributed on an "AS IS" BASIS,
12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13 * See the License for the specific language governing permissions and
14 * limitations under the License.
15 */
16
17/*
18 ONOS GUI -- Remote -- Web Socket Event Service
19 */
20(function () {
21 'use strict';
22
Simon Hunt3b0916b2015-01-23 11:06:56 -080023 var sid = 0;
24
Simon Hunt1e4a0012015-01-21 11:36:08 -080025 angular.module('onosRemote')
Simon Hunt3b0916b2015-01-23 11:06:56 -080026 .factory('WsEventService', [function () {
27
28 function sendEvent(ws, evType, payload) {
29 var p = payload || {};
30
31 ws.send({
32 event: evType,
33 sid: ++sid,
34 payload: p
35 });
36 }
37
38 function resetSid() {
39 sid = 0;
40 }
41
Simon Hunt1e4a0012015-01-21 11:36:08 -080042 return {
Simon Hunt3b0916b2015-01-23 11:06:56 -080043 sendEvent: sendEvent,
44 resetSid: resetSid
Simon Hunt1e4a0012015-01-21 11:36:08 -080045 };
46 }]);
47
48}());