Change more stuff
This commit is contained in:
parent
a0fcf0c275
commit
6e7143d532
2 changed files with 21 additions and 0 deletions
|
@ -70,6 +70,9 @@ func NewClient(devicePair *DevicePair, cryptor *crypto.Cryptor, logger zerolog.L
|
|||
}
|
||||
|
||||
func (c *Client) SetEventHandler(eventHandler EventHandler) {
|
||||
if eventHandler == nil {
|
||||
eventHandler = func(_ interface{}) {}
|
||||
}
|
||||
c.evHandler = eventHandler
|
||||
}
|
||||
|
||||
|
@ -124,6 +127,19 @@ func (c *Client) Reconnect(rpcKey []byte) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
func (c *Client) Disconnect() {
|
||||
c.rpc.CloseConnection()
|
||||
c.http.CloseIdleConnections()
|
||||
}
|
||||
|
||||
func (c *Client) IsConnected() bool {
|
||||
return c.rpc != nil
|
||||
}
|
||||
|
||||
func (c *Client) IsLoggedIn() bool {
|
||||
return c.devicePair != nil
|
||||
}
|
||||
|
||||
func (c *Client) triggerEvent(evt interface{}) {
|
||||
if c.evHandler != nil {
|
||||
c.evHandler(evt)
|
||||
|
|
|
@ -159,6 +159,11 @@ func (r *RPC) sendInitialData() error {
|
|||
return err
|
||||
}
|
||||
|
||||
_, convErr := r.client.Conversations.List(25)
|
||||
if convErr != nil {
|
||||
return convErr
|
||||
}
|
||||
|
||||
evtData := events.NewClientReady(sessionResponse)
|
||||
r.client.triggerEvent(evtData)
|
||||
r.client.sessionHandler.startAckInterval()
|
||||
|
|
Loading…
Reference in a new issue