File tree Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Expand file tree Collapse file tree 3 files changed +19
-3
lines changed Original file line number Diff line number Diff line change 19
19
"scripts" : {
20
20
"build" : " npm run clean && webpack && npm run build-copy-files" ,
21
21
"clean" : " shx rm -rf dist" ,
22
- "test" : " jest --config jest.config.json --coverage --detectOpenHandles " ,
22
+ "test" : " jest --config jest.config.json --coverage" ,
23
23
"format" : " prettier --write \" src/**/*.ts\" \" src/**/*.js\" " ,
24
24
"lint" : " tslint --project ./tsconfig.json" ,
25
25
"coverage" : " cat coverage/lcov.info | coveralls" ,
Original file line number Diff line number Diff line change @@ -8,10 +8,21 @@ export class Server {
8
8
private instance : HttpServer ;
9
9
private plotsContainer : IPlotsContainer = { } ;
10
10
private port : number ;
11
+ private sockets : { [ id : number ] : any } = { } ;
12
+ private nextSocketID = 0 ;
11
13
12
14
constructor ( port : number ) {
13
15
this . port = port ;
14
16
this . instance = this . createServer ( ) ;
17
+
18
+ this . instance . on ( 'connection' , ( socket ) => {
19
+ const id = this . nextSocketID ++ ;
20
+ this . sockets [ id ] = socket ;
21
+
22
+ socket . on ( 'close' , ( ) => {
23
+ delete this . sockets [ id ] ;
24
+ } ) ;
25
+ } ) ;
15
26
}
16
27
17
28
/**
@@ -36,6 +47,11 @@ export class Server {
36
47
if ( this . instance . address ( ) ) {
37
48
this . instance . close ( ) ;
38
49
}
50
+
51
+ for ( const socket of Object . values ( this . sockets ) ) {
52
+ socket . destroy ( ) ;
53
+ }
54
+
39
55
this . plotsContainer = { } ;
40
56
}
41
57
@@ -86,7 +102,7 @@ export class Server {
86
102
}
87
103
88
104
/**
89
- *
105
+ * Serves the website at http://localhost:PORT/plots/:id/index.html
90
106
* @param req
91
107
* @param res
92
108
*/
Original file line number Diff line number Diff line change @@ -77,4 +77,4 @@ describe('Server', () => {
77
77
server . clean ( ) ;
78
78
server = null ;
79
79
} ) ;
80
- } ) ;
80
+ } ) ;
You can’t perform that action at this time.
0 commit comments