1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2024-10-01 00:06:11 -04:00
v2fly/app/internal/space.go
Darien Raymond b6ed26aedf pubsub
2015-12-11 14:56:10 +00:00

61 lines
1.2 KiB
Go

package internal
import (
"github.com/v2ray/v2ray-core/app"
)
type Space struct {
packetDispatcher PacketDispatcherWithContext
dnsCache DnsCacheWithContext
pubsub PubsubWithContext
tag string
}
func NewSpace(tag string, packetDispatcher PacketDispatcherWithContext, dnsCache DnsCacheWithContext, pubsub PubsubWithContext) *Space {
return &Space{
tag: tag,
packetDispatcher: packetDispatcher,
dnsCache: dnsCache,
pubsub: pubsub,
}
}
func (this *Space) HasPacketDispatcher() bool {
return this.packetDispatcher != nil
}
func (this *Space) PacketDispatcher() app.PacketDispatcher {
return &contextedPacketDispatcher{
packetDispatcher: this.packetDispatcher,
context: &contextImpl{
callerTag: this.tag,
},
}
}
func (this *Space) HasDnsCache() bool {
return this.dnsCache != nil
}
func (this *Space) DnsCache() app.DnsCache {
return &contextedDnsCache{
dnsCache: this.dnsCache,
context: &contextImpl{
callerTag: this.tag,
},
}
}
func (this *Space) HasPubsub() bool {
return this.pubsub != nil
}
func (this *Space) Pubsub() app.Pubsub {
return &contextedPubsub{
pubsub: this.pubsub,
context: &contextImpl{
callerTag: this.tag,
},
}
}