Merge pull request #232 from PaladinTyrion/master
fix map usage in events.go
This commit is contained in:
commit
8ecd8eb2fc
|
@ -92,14 +92,14 @@ func (uq *UserEventQueue) AddHandler(handlers ...Handler) {
|
|||
|
||||
// New initializes a user event queue with the specified wide session id.
|
||||
func (ueqs queues) New(sid string) *UserEventQueue {
|
||||
q := ueqs[sid]
|
||||
if nil != q {
|
||||
|
||||
if q, ok := ueqs[sid]; ok {
|
||||
logger.Warnf("Already exist a user queue in session [%s]", sid)
|
||||
|
||||
return q
|
||||
}
|
||||
|
||||
q = &UserEventQueue{
|
||||
q := &UserEventQueue{
|
||||
Sid: sid,
|
||||
Queue: make(chan *Event, maxQueueLength),
|
||||
}
|
||||
|
@ -124,14 +124,11 @@ func (ueqs queues) New(sid string) *UserEventQueue {
|
|||
|
||||
// Close closes a user event queue with the specified wide session id.
|
||||
func (ueqs queues) Close(sid string) {
|
||||
q := ueqs[sid]
|
||||
if nil == q {
|
||||
return
|
||||
}
|
||||
|
||||
if q, ok := ueqs[sid]; ok {
|
||||
close(q.Queue)
|
||||
|
||||
delete(ueqs, sid)
|
||||
}
|
||||
}
|
||||
|
||||
// Handler represents an event handler.
|
||||
|
|
Loading…
Reference in New Issue