blob: 86e0625b7a55d70809b58b44b4bc0f64b0b2e453 [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 */
Sean Condonfd6d11b2018-06-02 20:29:49 +010024@Injectable({
25 providedIn: 'root',
26})
Sean Condon83fc39f2018-04-19 18:56:13 +010027export class WSock {
28
29 constructor(
30 private log: LogService,
31 ) {
32 this.log.debug('WSockService constructed');
33 }
34
35
36 newWebSocket(url) {
37 let ws = null;
38 try {
39 ws = new WebSocket(url);
40 } catch (e) {
41 this.log.error('Unable to create web socket:', e);
42 }
43 return ws;
44 }
45
46}