]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blob - client/src/app/videos/video-watch/webtorrent.service.ts
Fix refresh token expired handling
[github/Chocobozzz/PeerTube.git] / client / src / app / videos / video-watch / webtorrent.service.ts
1 import { Injectable } from '@angular/core'
2 import { Subject } from 'rxjs/Subject'
3
4 import * as WebTorrent from 'webtorrent'
5
6 @Injectable()
7 export class WebTorrentService {
8 errors = new Subject<string | Error>()
9
10 private client: WebTorrent.Instance
11
12 constructor () {
13 this.client = new WebTorrent({ dht: false })
14
15 this.client.on('error', err => this.errors.next(err))
16 }
17
18 add (magnetUri: string, callback: (torrent: WebTorrent.Torrent) => any) {
19 return this.client.add(magnetUri, callback)
20 }
21
22 remove (magnetUri: string) {
23 return this.client.remove(magnetUri)
24 }
25
26 has (magnetUri: string) {
27 return this.client.get(magnetUri) !== null
28 }
29 }