Make channel type more specific (Packet instead of interface{})

Thanks to Genofire for spotting this
This commit is contained in:
Mickael Remond 2019-06-10 10:58:41 +02:00
parent 36e3379f5a
commit 411619c2ef
No known key found for this signature in database
GPG key ID: E6F6045D79965AA3
2 changed files with 6 additions and 6 deletions

View file

@ -72,7 +72,7 @@ type Client struct {
// TCP level connection / can be replaced by a TLS session after starttls
conn net.Conn
// Packet channel
RecvChannel chan interface{}
RecvChannel chan Packet
// Track and broadcast connection state
EventManager
}
@ -110,7 +110,7 @@ func NewClient(config Config) (c *Client, err error) {
}
// Create a default channel that developers can override
c.RecvChannel = make(chan interface{})
c.RecvChannel = make(chan Packet)
return
}
@ -174,7 +174,7 @@ func (c *Client) SetHandler(handler EventHandler) {
// Recv abstracts receiving preparsed XMPP packets from a channel.
// Channel allow client to receive / dispatch packets in for range loop.
// TODO: Deprecate this function in favor of reading directly from the RecvChannel ?
func (c *Client) Recv() <-chan interface{} {
func (c *Client) Recv() <-chan Packet {
return c.RecvChannel
}

View file

@ -38,7 +38,7 @@ type ComponentOptions struct {
// Communication with developer client / StreamManager
// Packet channel
RecvChannel chan interface{}
RecvChannel chan Packet
// Track and broadcast connection state
EventManager
}
@ -60,7 +60,7 @@ type Component struct {
func NewComponent(opts ComponentOptions) (*Component, error) {
c := Component{ComponentOptions: opts}
// Create a default channel that developers can override
c.RecvChannel = make(chan interface{})
c.RecvChannel = make(chan Packet)
return &c, nil
}
@ -122,7 +122,7 @@ func (c *Component) SetHandler(handler EventHandler) {
// Recv abstracts receiving preparsed XMPP packets from a channel.
// Channel allow client to receive / dispatch packets in for range loop.
// TODO: Deprecate this function in favor of reading directly from the RecvChannel ?
func (c *Component) Recv() <-chan interface{} {
func (c *Component) Recv() <-chan Packet {
return c.RecvChannel
}