Skip to content

Commit 2cd7ff4

Browse files
committed
refactor: use socket.io-client instead of ngx-socket-io
1 parent 1f9482f commit 2cd7ff4

File tree

8 files changed

+889
-699
lines changed

8 files changed

+889
-699
lines changed

apps/web/src/app/app.module.ts

-7
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,10 @@ import { MatSidenavModule } from '@angular/material/sidenav';
1313
import { MatListModule } from '@angular/material/list';
1414
import { PlotComponent } from './components/plot/plot.component';
1515
import { PlotsComponent } from './components/plots/plots.component';
16-
import { SocketIoModule, SocketIoConfig } from 'ngx-socket-io';
1716
import { SocketService } from './services/socket.service';
1817
import { DragDropModule } from '@angular/cdk/drag-drop';
1918
import { MatCardModule } from '@angular/material/card';
2019

21-
const config: SocketIoConfig = {
22-
url: '',
23-
options: { transports: ['polling'] },
24-
};
25-
2620
@NgModule({
2721
declarations: [
2822
AppComponent,
@@ -40,7 +34,6 @@ const config: SocketIoConfig = {
4034
HttpClientModule,
4135
MatSidenavModule,
4236
MatListModule,
43-
SocketIoModule.forRoot(config),
4437
DragDropModule,
4538
MatCardModule,
4639
],

apps/web/src/app/services/socket.service.ts

+7-2
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
import { Injectable } from '@angular/core';
2-
import { Socket } from 'ngx-socket-io';
2+
import { io } from 'socket.io-client';
3+
import { environment } from '../../environments/environment';
34

45
@Injectable()
56
export class SocketService {
6-
constructor(private socket: Socket) {
7+
socket;
8+
9+
constructor() {
10+
this.socket = io(environment.socketIoEndpoint, { transports: ['polling'] });
11+
712
this.socket.on('connect', () => {
813
console.log('connected');
914
});
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
export const environment = {
22
production: true,
3+
socketIoEndpoint: '',
34
};

apps/web/src/environments/environment.ts

+1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
export const environment = {
66
production: false,
7+
socketIoEndpoint: '',
78
};
89

910
/*

libs/core/src/lib/server/plots/plots.gateway.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ export class PlotsGateway implements OnGatewayConnection, OnGatewayDisconnect {
5555
this.clientMap.delete(client);
5656

5757
if (this.clientMap.size === 0) {
58-
this.bridgeService.shutdown$.next();
58+
this.bridgeService.shutdown$.next(null);
5959
}
6060
}
6161
}

libs/core/src/lib/server/services/bridge.service.ts

+1-1
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,6 @@ export class BridgeService {
1818
}
1919

2020
shutdown() {
21-
this.shutdown$.next();
21+
this.shutdown$.next(null);
2222
}
2323
}

0 commit comments

Comments
 (0)