Closed heliosgo closed 8 months ago
Describe the bug When multiple events are set in empty namespace, and include OnNativeMessage, it may panic if received native message before connectedNamespaces is set.
OnNativeMessage
connectedNamespaces
Screenshots
Here is some source code I found.
func (c *Conn) handleMessage(msg Message) error { if msg.isInvalid { return ErrInvalidPayload } if msg.IsNative && c.allowNativeMessages { ns := c.Namespace("") return ns.events.fireEvent(ns, msg) // panic } ...... return nil }
I think the code should be like this.
func (c *Conn) handleMessage(msg Message) error { if msg.isInvalid { return ErrInvalidPayload } if msg.IsNative && c.shouldHandleOnlyNativeMessages { // this line ns := c.Namespace("") return ns.events.fireEvent(ns, msg) } ...... return nil }
Describe the bug When multiple events are set in empty namespace, and include
OnNativeMessage
, it may panic if received native message beforeconnectedNamespaces
is set.Screenshots
Here is some source code I found.
I think the code should be like this.