space.go 690 B

123456789101112131415161718192021222324252627282930313233343536
  1. package app
  2. type Space struct {
  3. packetDispatcher PacketDispatcher
  4. dnsCache DnsCache
  5. }
  6. func NewSpace() *Space {
  7. return new(Space)
  8. }
  9. func (this *Space) Bind(object interface{}) {
  10. if packetDispatcher, ok := object.(PacketDispatcher); ok {
  11. this.packetDispatcher = packetDispatcher
  12. }
  13. if dnsCache, ok := object.(DnsCache); ok {
  14. this.dnsCache = dnsCache
  15. }
  16. }
  17. func (this *Space) HasPacketDispatcher() bool {
  18. return this.packetDispatcher != nil
  19. }
  20. func (this *Space) PacketDispatcher() PacketDispatcher {
  21. return this.packetDispatcher
  22. }
  23. func (this *Space) HasDnsCache() bool {
  24. return this.dnsCache != nil
  25. }
  26. func (this *Space) DnsCache() DnsCache {
  27. return this.dnsCache
  28. }