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

Commit

Permalink
refactor: connection -> connect to stick to Socket.io doc
Browse files Browse the repository at this point in the history
and also fix a log message when user is created
  • Loading branch information
severo committed Jan 23, 2020
1 parent e43a3da commit 4fd2ca8
Show file tree
Hide file tree
Showing 8 changed files with 21 additions and 21 deletions.
10 changes: 10 additions & 0 deletions src/domain/events/toserver/connect.event.spec.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
import { expect } from 'chai'
import { ConnectEvent } from './connect.event'

describe('Events', () => {
describe('ConnectEvent', () => {
it("should have 'connect' event as name", () => {
expect(ConnectEvent.eventName).to.equal('connect')
})
})
})
5 changes: 5 additions & 0 deletions src/domain/events/toserver/connect.event.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
import { EventToServer } from './event.to.server'

export class ConnectEvent {
static readonly eventName: string = EventToServer.Connect
}
10 changes: 0 additions & 10 deletions src/domain/events/toserver/connection.event.spec.ts

This file was deleted.

5 changes: 0 additions & 5 deletions src/domain/events/toserver/connection.event.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/domain/events/toserver/event.to.server.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
export class EventToServer {
static readonly Connection = 'connection'
static readonly Connect = 'connect'
// static readonly Disconnection = 'disconnection'

// static readonly JoinRoom = 'join-room'
Expand Down
2 changes: 1 addition & 1 deletion src/domain/events/toserver/index.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
export * from './connection.event'
export * from './connect.event'
// export * from './disconnection.event'

// export * from './join.room.event'
Expand Down
2 changes: 1 addition & 1 deletion src/socket.io/socket.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ describe('Server', () => {
mockLogger
.getInfoLogs()
.should.include.something.that.have.string(
'New user created for socket'
'New user created (client socket'
)
})
it('should send the ordered list of users, and their id should correspond to client sockets ids', async () => {
Expand Down
6 changes: 3 additions & 3 deletions src/socket.io/socket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import Automerge from 'automerge'
import { Constants } from './constants'
import { Guard, ConsoleLogger } from '../shared/index'
import {
ConnectionEvent,
ConnectEvent,
UpdateStateEvent,
UpdateUserNameEvent,
UpdateUserColorEvent,
Expand All @@ -19,7 +19,7 @@ class Socket {
public connect() {
this.io
.of('/occupapp-beta')
.on(ConnectionEvent.eventName, (socket: SocketIOClient.Socket) => {
.on(ConnectEvent.eventName, (socket: SocketIOClient.Socket) => {
// 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 Expand Up @@ -133,7 +133,7 @@ class Socket {
private createUser = (id: SocketIOClient.Socket['id']): User => {
const newUser = new User(id)
this.users.set(id, newUser)
this.log.info(`getOrCreateUser`, `New user created for socket ${id}`)
this.log.info(`createUser`, `New user created (client socket ${id})`)
return newUser
}

Expand Down

0 comments on commit 4fd2ca8

Please sign in to comment.