Skip to content
This repository has been archived by the owner on Nov 10, 2022. It is now read-only.

Commit

Permalink
feat: add log when a new client has connected
Browse files Browse the repository at this point in the history
and improve test on logs
  • Loading branch information
severo committed Jan 23, 2020
1 parent 4fd2ca8 commit 3002881
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 2 deletions.
10 changes: 8 additions & 2 deletions src/socket.io/socket.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,17 @@ describe('Server', () => {
it('should create a new user', async () => {
mockLogger
.getInfoLogs()
.should.include.something.that.have.string(
'New user created (client socket'
.should.include.something.that.equals(
`Connection from socket ${client.id}`
)
mockLogger
.getInfoLogs()
.should.include.something.that.equals(
`createUser - New user created (client socket ${client.id})`
)
})
it('should send the ordered list of users, and their id should correspond to client sockets ids', async () => {
// arrange
await new Promise(resolve => passiveClient.on('connect', resolve))
const getUsersList = (): Promise<ExportedUser[]> =>
new Promise(resolve =>
Expand Down
2 changes: 2 additions & 0 deletions src/socket.io/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,8 @@ class Socket {
this.io
.of('/occupapp-beta')
.on(ConnectEvent.eventName, (socket: SocketIOClient.Socket) => {
this.log.info(`Connection from socket ${socket.id}`)

// Note that a new socket (and this socket.id) is created on each
// connection. There is no persistence for a same user between
// connections
Expand Down

0 comments on commit 3002881

Please sign in to comment.