Class: Async::Container::Notify::Server::Context

Inherits:
Object
  • Object
show all
Defined in:
lib/async/container/notify/server.rb

Instance Method Summary collapse

Constructor Details

#initialize(path) ⇒ Context

Returns a new instance of Context.



79
80
81
82
83
84
85
86
87
88
# File 'lib/async/container/notify/server.rb', line 79

def initialize(path)
	@path = path
	@endpoint = IO::Endpoint.unix(@path, ::Socket::SOCK_DGRAM)
	
	Sync do
		@bound = @endpoint.bind
	end
	
	@state = {}
end

Instance Method Details

#closeObject



90
91
92
93
94
95
96
# File 'lib/async/container/notify/server.rb', line 90

def close
	Sync do
		@bound.close
	end
	
	File.unlink(@path)
end

#receiveObject



98
99
100
101
102
103
104
105
106
# File 'lib/async/container/notify/server.rb', line 98

def receive
	while true
		data, address, flags, *controls = @bound.recvmsg(MAXIMUM_MESSAGE_SIZE)
		
		message = Server.load(data)
		
		yield message
	end
end