Postconnect method should receive an xmpp.Sender and not directly a client

Fixes #80
This commit is contained in:
Mickael Remond 2019-06-29 09:35:33 +02:00
parent a465e370e2
commit 318e5e8a50
No known key found for this signature in database
GPG Key ID: E6F6045D79965AA3

View File

@ -24,11 +24,14 @@ import (
// set callback and trigger reconnection. // set callback and trigger reconnection.
type StreamClient interface { type StreamClient interface {
Connect() error Connect() error
Send(packet stanza.Packet) error
SendRaw(packet string) error
Disconnect() Disconnect()
SetHandler(handler EventHandler) SetHandler(handler EventHandler)
} }
// Sender is an interface provided by Stream clients to allow sending XMPP data. // Sender is an interface provided by Stream clients to allow sending XMPP data.
// It is mostly use in callback to pass a limited subset of the stream client interface
type Sender interface { type Sender interface {
Send(packet stanza.Packet) error Send(packet stanza.Packet) error
SendRaw(packet string) error SendRaw(packet string) error
@ -46,7 +49,7 @@ type StreamManager struct {
wg sync.WaitGroup wg sync.WaitGroup
} }
type PostConnect func(c StreamClient) type PostConnect func(c Sender)
// NewStreamManager creates a new StreamManager structure, intended to support // NewStreamManager creates a new StreamManager structure, intended to support
// handling XMPP client state event changes and auto-trigger reconnection // handling XMPP client state event changes and auto-trigger reconnection
@ -59,7 +62,7 @@ func NewStreamManager(client StreamClient, pc PostConnect) *StreamManager {
} }
} }
// Run launchs the connection of the underlying client or component // Run launches the connection of the underlying client or component
// and wait until Disconnect is called, or for the manager to terminate due // and wait until Disconnect is called, or for the manager to terminate due
// to an unrecoverable error. // to an unrecoverable error.
func (sm *StreamManager) Run() error { func (sm *StreamManager) Run() error {