Created
October 25, 2017 17:31
-
-
Save logrusorgru/a1bb701c47df9ff565edb25e0763a141 to your computer and use it in GitHub Desktop.
is initialized
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
type MessengerFactory struct { | |
factory.MessengerFactory | |
isInitialized bool | |
} | |
func (m *MessengerFactory) IsInitialized() bool { return m.isInitialized } | |
func (m *MessengerFactory) Connect(address string) (conn *Connection, err error) { | |
return m.ConnectWithConfig(address, nil) | |
} | |
func (m *MessengerFactory) ConnectWithConfig(address string, config *ConnConfig) (conn *Connection, err error) { | |
if conn, err = m.MessengerFactory.ConnectWithConfig(address, config); err == nil { | |
m.isInitialized = true | |
} | |
return | |
} | |
func (m *MessengerFactory) Listen(address string) (err error) { | |
if err = m.MessengerFactory.Listen(address); err == nil { | |
m.isInitialized = true | |
} | |
return | |
} | |
func (m *MessengerFactory) ForEachConn(fn func(connection *Connection)) { | |
if m.isInitialized == false { | |
return | |
} | |
m.MessengerFactory.ForEachConn(fn) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment