Tidy up slightly
This commit is contained in:
1 parent
a78766524b
commit
2cab8415f2
1 file changed
+13
-10
+13
-10
@@ -98,37 +98,40 @@ const (
|
|||||||
CMessageReceived = iota
|
CMessageReceived = iota
|
||||||
)
|
)
|
||||||
|
|
||||||
type Interaction struct {
|
type MDNSInteraction struct {
|
||||||
code int
|
code int
|
||||||
resultChan chan<- interface{}
|
resultChan chan<- interface{}
|
||||||
}
|
payload interface{}
|
||||||
|
|
||||||
type MDNSInteraction struct {
|
|
||||||
Interaction
|
|
||||||
payload interface{}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Async
|
// Async
|
||||||
func (c *MDNSClient) Shutdown() {
|
func (c *MDNSClient) Shutdown() {
|
||||||
c.queryChan <- &MDNSInteraction{Interaction: Interaction{code: CShutdown}}
|
c.queryChan <- &MDNSInteraction{code: CShutdown}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Async
|
// Async
|
||||||
func (c *MDNSClient) SendQuery(name string, querytype uint16, responseCh chan<- *ResponseA) {
|
func (c *MDNSClient) SendQuery(name string, querytype uint16, responseCh chan<- *ResponseA) {
|
||||||
c.queryChan <- &MDNSInteraction{Interaction: Interaction{code: CSendQuery}, payload: mDNSQueryInfo{name, querytype, responseCh}}
|
c.queryChan <- &MDNSInteraction{
|
||||||
|
code: CSendQuery,
|
||||||
|
payload: mDNSQueryInfo{name, querytype, responseCh},
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Sync
|
// Sync
|
||||||
func (c *MDNSClient) IsInflightQuery(m *dns.Msg) bool {
|
func (c *MDNSClient) IsInflightQuery(m *dns.Msg) bool {
|
||||||
resultChan := make(chan interface{})
|
resultChan := make(chan interface{})
|
||||||
c.queryChan <- &MDNSInteraction{Interaction: Interaction{code: CIsInflightQuery, resultChan: resultChan}, payload: m}
|
c.queryChan <- &MDNSInteraction{
|
||||||
|
code: CIsInflightQuery,
|
||||||
|
resultChan: resultChan,
|
||||||
|
payload: m,
|
||||||
|
}
|
||||||
result := <-resultChan
|
result := <-resultChan
|
||||||
return result.(bool)
|
return result.(bool)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Async - called from dns library multiplexer
|
// Async - called from dns library multiplexer
|
||||||
func (c *MDNSClient) ResponseCallback(r *dns.Msg) {
|
func (c *MDNSClient) ResponseCallback(r *dns.Msg) {
|
||||||
c.queryChan <- &MDNSInteraction{Interaction: Interaction{code: CMessageReceived}, payload: r}
|
c.queryChan <- &MDNSInteraction{code: CMessageReceived, payload: r}
|
||||||
}
|
}
|
||||||
|
|
||||||
// ACTOR server
|
// ACTOR server
|
||||||
|
|||||||
Reference in new issue
Block a user