]> git.immae.eu Git - github/Chocobozzz/PeerTube.git/blame - 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
CommitLineData
df98563e
C
1import { Injectable } from '@angular/core'
2import { Subject } from 'rxjs/Subject'
d3ef341a 3
df98563e 4import * as WebTorrent from 'webtorrent'
d3ef341a
C
5
6@Injectable()
7export class WebTorrentService {
33c4972d 8 errors = new Subject<string | Error>()
13fc89f4 9
33c4972d 10 private client: WebTorrent.Instance
d3ef341a 11
df98563e
C
12 constructor () {
13 this.client = new WebTorrent({ dht: false })
13fc89f4 14
33c4972d 15 this.client.on('error', err => this.errors.next(err))
d3ef341a
C
16 }
17
33c4972d 18 add (magnetUri: string, callback: (torrent: WebTorrent.Torrent) => any) {
df98563e 19 return this.client.add(magnetUri, callback)
d3ef341a
C
20 }
21
df98563e
C
22 remove (magnetUri: string) {
23 return this.client.remove(magnetUri)
d3ef341a 24 }
92fb909c 25
df98563e
C
26 has (magnetUri: string) {
27 return this.client.get(magnetUri) !== null
92fb909c 28 }
d3ef341a 29}