|
@@ -3,6 +3,7 @@ import { Socket as ClientSocket } from 'socket.io-client'
|
|
|
import { Socket as SocketForConnectedClient } from "socket.io"
|
|
|
import { handleClientSocketConnection, handleNewSocketClient, startClientSocketConnection, startSocketServer } from "../utils/socket.utils";
|
|
|
import { ClientObject, ConnectionState, Info, Transport, TransportEvent, TransportMessage, TransportService } from "../interface/connector.interface";
|
|
|
+import { error } from "console";
|
|
|
|
|
|
/* Just code in the context that this websocket service will be handling multiple UI clients. Can think about the server communication at a later time. */
|
|
|
export class WebsocketTransportService implements TransportService {
|
|
@@ -22,9 +23,14 @@ export class WebsocketTransportService implements TransportService {
|
|
|
startSocketServer(port).subscribe({
|
|
|
next: (connectedClient: SocketForConnectedClient) => {
|
|
|
console.log(`WebsocketTransport Server Started...`)
|
|
|
- handleNewSocketClient(connectedClient, this.connectedClientSocket).subscribe(this.transportEvent)
|
|
|
+ handleNewSocketClient(connectedClient, this.connectedClientSocket).subscribe({
|
|
|
+ next: event => this.transportEvent.next(event),
|
|
|
+ error: error => console.error(error),
|
|
|
+ complete: () => console.log(`Client ${connectedClient.id} disconnected...`)
|
|
|
+ })
|
|
|
},
|
|
|
error: error => console.error(error),
|
|
|
+ complete: () => console.log(`...`)
|
|
|
})
|
|
|
}
|
|
|
|