Skip to content

Commit

Permalink
log when a client disconnects
Browse files Browse the repository at this point in the history
  • Loading branch information
adonese committed Oct 16, 2022
1 parent bf14871 commit 49624ca
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 0 deletions.
6 changes: 6 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -74,4 +74,10 @@ And the directory tree is like the following:
│   ├── 000002_add_date_chats.down.sqlite3
│   └── 000002_add_date_chats.up.sqlite3
└── test.db
```

### How to create database migrations

```shell
$ migrate create -ext sqlite3 -dir migrations -seq add_date_chats
```
1 change: 1 addition & 0 deletions hub.go
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ func (h *Hub) Run() {
case client := <-h.register:
h.clients[client.ID] = client
case client := <-h.unregister:
log.Printf("client ID: %s got disconnected", client.ID)
if _, ok := h.clients[client.ID]; ok {
delete(h.clients, client.ID)
close(client.send)
Expand Down

0 comments on commit 49624ca

Please sign in to comment.