-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added socket io for showing download progress on server & client
- Loading branch information
Showing
14 changed files
with
245 additions
and
36 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export const environment = { | ||
serverUrl: 'https://0a40-5-147-251-186.ngrok-free.app', | ||
// serverUrl: 'https://0a40-5-147-251-186.ngrok-free.app', | ||
serverUrl: 'http://localhost:3000', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
import { Injectable } from '@angular/core'; | ||
import { Socket, io } from 'socket.io-client'; | ||
import { environment } from '../environment/environment'; | ||
import { Observable } from 'rxjs'; | ||
|
||
export interface ProgressData { | ||
totalDownloaded: number; | ||
totalSize: number; | ||
} | ||
|
||
const downloadEvent = 'download-progress'; | ||
|
||
@Injectable({ providedIn: 'root' }) | ||
export class SocketService { | ||
private socket: Socket; | ||
private progressData: Observable<ProgressData>; | ||
|
||
constructor() { | ||
this.socket = io(environment.serverUrl); | ||
this.progressData = new Observable<ProgressData>((subscriber) => { | ||
this.socket.on(downloadEvent, (data: ProgressData) => { | ||
subscriber.next(data); | ||
}); | ||
}); | ||
} | ||
|
||
public connect() { | ||
this.socket.connect(); | ||
} | ||
|
||
public getProgressData() { | ||
return this.progressData; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -7,5 +7,4 @@ COPY package.json package-lock.json ./ | |
RUN npm install | ||
|
||
COPY . . | ||
EXPOSE 80 | ||
CMD ["npm", "run", "start"] |
Oops, something went wrong.