Skip to content

Commit

Permalink
chat service update
Browse files Browse the repository at this point in the history
- readme update
- room map key fixed

Author: [email protected]
  • Loading branch information
thanhpp committed Jan 21, 2022
1 parent f11f541 commit dbb027c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@
- [ ] delete_conversation

- TODO (data whatever)
- [ ] Tạo connection || ws://localhost:12000/ws ||
- [ ] Join room
- [x] Tạo connection || ws://localhost:12000/ws ||
- [x] Join room
- ```go
type WsMessage struct {
MsgID string `json:"message_id"` // null
Expand All @@ -91,7 +91,7 @@
Content string `json:"content"` // null
}
```
- [ ] send message
- [x] send message
- ```go
type WsMessage struct {
MsgID string `json:"message_id"` // null
Expand Down
4 changes: 4 additions & 0 deletions internal/auco/app/wsmap.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ func newWsRoomMap() *wsRoomMap {

func (rm *wsRoomMap) add(room *WsRoom) {
rm.rw.Lock()
logger.Debugf("WsRoomMap: added room %s", room.key())
rm.m[room.key()] = room
rm.rw.Unlock()
}
Expand All @@ -36,6 +37,9 @@ func (rm *wsRoomMap) delete(room *WsRoom) {

func (rm *wsRoomMap) findByUserIDs(userA, userB string) (*WsRoom, bool) {
rm.rw.RLock()
if userA > userB {
userA, userB = userB, userA
}
room, ok := rm.m[userA+"-"+userB]
rm.rw.RUnlock()
return room, ok
Expand Down

0 comments on commit dbb027c

Please sign in to comment.