mirror of
https://github.com/gissleh/irc.git
synced 2026-09-29 00:05:34 +00:00
client: Added Ready() method.
This commit is contained in:
@@ -76,6 +76,7 @@ type Client struct {
|
||||
user string
|
||||
host string
|
||||
quit bool
|
||||
ready bool
|
||||
isupport isupport.ISupport
|
||||
values map[string]interface{}
|
||||
|
||||
@@ -161,6 +162,14 @@ func (client *Client) CapEnabled(cap string) bool {
|
||||
return client.capEnabled[cap]
|
||||
}
|
||||
|
||||
// Ready returns true if the client is marked as ready, which means that it has received the MOTD.
|
||||
func (client *Client) Ready() bool {
|
||||
client.mutex.RLock()
|
||||
defer client.mutex.RUnlock()
|
||||
|
||||
return client.ready
|
||||
}
|
||||
|
||||
// Connect connects to the server by addr.
|
||||
func (client *Client) Connect(addr string, ssl bool) (err error) {
|
||||
var conn net.Conn
|
||||
@@ -214,6 +223,7 @@ func (client *Client) Connect(addr string, ssl bool) (err error) {
|
||||
|
||||
client.mutex.Lock()
|
||||
client.conn = nil
|
||||
client.ready = false
|
||||
client.mutex.Unlock()
|
||||
|
||||
client.Emit(NewEvent("client", "disconnect"))
|
||||
@@ -1151,6 +1161,10 @@ func (client *Client) handleEvent(event *Event) {
|
||||
client.EmitNonBlocking(rejoinEvent)
|
||||
}
|
||||
|
||||
client.mutex.Lock()
|
||||
client.ready = true
|
||||
client.mutex.Unlock()
|
||||
|
||||
client.EmitNonBlocking(NewEvent("hook", "ready"))
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user