fix map usage in events.go
This commit is contained in:
parent
bb12838d1c
commit
38b64b491a
|
@ -92,14 +92,14 @@ func (uq *UserEventQueue) AddHandler(handlers ...Handler) {
|
||||||
|
|
||||||
// New initializes a user event queue with the specified wide session id.
|
// New initializes a user event queue with the specified wide session id.
|
||||||
func (ueqs queues) New(sid string) *UserEventQueue {
|
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)
|
logger.Warnf("Already exist a user queue in session [%s]", sid)
|
||||||
|
|
||||||
return q
|
return q
|
||||||
}
|
}
|
||||||
|
|
||||||
q = &UserEventQueue{
|
q := &UserEventQueue{
|
||||||
Sid: sid,
|
Sid: sid,
|
||||||
Queue: make(chan *Event, maxQueueLength),
|
Queue: make(chan *Event, maxQueueLength),
|
||||||
}
|
}
|
||||||
|
@ -124,15 +124,12 @@ func (ueqs queues) New(sid string) *UserEventQueue {
|
||||||
|
|
||||||
// Close closes a user event queue with the specified wide session id.
|
// Close closes a user event queue with the specified wide session id.
|
||||||
func (ueqs queues) Close(sid string) {
|
func (ueqs queues) Close(sid string) {
|
||||||
q := ueqs[sid]
|
|
||||||
if nil == q {
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
|
if q, ok := ueqs[sid]; ok {
|
||||||
close(q.Queue)
|
close(q.Queue)
|
||||||
|
|
||||||
delete(ueqs, sid)
|
delete(ueqs, sid)
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
// Handler represents an event handler.
|
// Handler represents an event handler.
|
||||||
type Handler interface {
|
type Handler interface {
|
||||||
|
|
Loading…
Reference in New Issue