mirror of
https://github.com/fosrl/olm.git
synced 2026-02-08 05:56:41 +00:00
Unix: handle encrypted messages
This commit is contained in:
@@ -27,7 +27,8 @@ type Client struct {
|
||||
isConnected bool
|
||||
reconnectMux sync.RWMutex
|
||||
|
||||
onConnect func() error
|
||||
onConnect func() error
|
||||
onTokenUpdate func(token string)
|
||||
}
|
||||
|
||||
type ClientOption func(*Client)
|
||||
@@ -45,6 +46,10 @@ func (c *Client) OnConnect(callback func() error) {
|
||||
c.onConnect = callback
|
||||
}
|
||||
|
||||
func (c *Client) OnTokenUpdate(callback func(token string)) {
|
||||
c.onTokenUpdate = callback
|
||||
}
|
||||
|
||||
// NewClient creates a new Olm client
|
||||
func NewClient(olmID, secret string, endpoint string, opts ...ClientOption) (*Client, error) {
|
||||
config := &Config{
|
||||
@@ -266,6 +271,8 @@ func (c *Client) establishConnection() error {
|
||||
return fmt.Errorf("failed to get token: %w", err)
|
||||
}
|
||||
|
||||
c.onTokenUpdate(token)
|
||||
|
||||
// Parse the base URL to determine protocol and hostname
|
||||
baseURL, err := url.Parse(c.baseURL)
|
||||
if err != nil {
|
||||
|
||||
Reference in New Issue
Block a user