0
私のAngular 5プロジェクトではatmosphere.jsを使用する必要があります。Angular 5 and atmosphere.js
は、私はこれらのステップを行ってきた:
npm install --save @types/atmosphere.js
npm install --save atmosphere.js
と私はサービスを作成しました:
import { Injectable } from '@angular/core';
import * as Rx from 'rxjs';
import * as Atmosphere from 'atmosphere.js';
import {Subject} from 'rxjs/Subject';
@Injectable()
export class WebsocketService {
public eventsSubject: Rx.Subject<any> = new Rx.Subject<any>();
private url:string = "http://localhost:4200/ws/register";
private socket: Atmosphere.Atmosphere;
private subSocket: any;
private request: Atmosphere.Request;
public dataStream: Subject<any> = new Subject<any>();
constructor() {
...
try {
this.subSocket = this.socket.subscribe(this.request);
} catch (e) {
console.log("Error: " + e);
}
}
が、ソケットは常に定義されていません。
私のエラーはどこですか?あなたが実際に何らかの方法であなたのソケットをインスタンス化する必要があり
おかげ
素晴らしいです。 tnx –