blob: 176b5d3f633452b7e9b14d02f77727ba753f7d62 [file] [log] [blame]
Sean Condon83fc39f2018-04-19 18:56:13 +01001/*
2 * Copyright 2015-present Open Networking Foundation
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 */
16import { Injectable } from '@angular/core';
17import { LogService } from '../../log.service';
18
19/**
20 * ONOS GUI -- Remote -- Web Socket Wrapper Service
21 *
22 * This service provided specifically so that it can be mocked in unit tests.
23 */
24@Injectable()
25export class WSock {
26
27 constructor(
28 private log: LogService,
29 ) {
30 this.log.debug('WSockService constructed');
31 }
32
33
34 newWebSocket(url) {
35 let ws = null;
36 try {
37 ws = new WebSocket(url);
38 } catch (e) {
39 this.log.error('Unable to create web socket:', e);
40 }
41 return ws;
42 }
43
44}