Module: EventMachine::Protocols::Zmq2::ConnectionMixin

Included in:
InProc::Connection, SocketConnection
Defined in:
lib/em/protocols/zmq2/connection.rb

Instance Method Summary collapse

Instance Method Details

#not_too_busy?Boolean

Returns:

  • (Boolean)


13
14
15
16
17
18
19
# File 'lib/em/protocols/zmq2/connection.rb', line 13

def not_too_busy?
  !error? && (!@socket.do_balance || begin
    free = _not_too_busy?
    self.notify_when_free = !free
    free
  end)
end

#post_initObject



21
22
23
# File 'lib/em/protocols/zmq2/connection.rb', line 21

def post_init
  send_strings @socket.identity
end

#receive_strings(message) ⇒ Object



25
26
27
28
29
30
31
32
# File 'lib/em/protocols/zmq2/connection.rb', line 25

def receive_strings(message)
  unless @peer_identity
    peer_identity = message.first
    @peer_identity = @socket.register_peer(peer_identity, self)
  else
    @socket.receive_message_and_peer message, @peer_identity
  end
end

#sent_dataObject

use watching on outbound queue when possible rely on github.com/eventmachine/eventmachine/pull/317 if were accepted or on github.com/funny-falcon/eventmachine/tree/sent_data use timers otherwise



9
10
11
# File 'lib/em/protocols/zmq2/connection.rb', line 9

def sent_data
  @socket.peer_free(@peer_identity, self) if not_too_busy?
end

#unbindObject



34
35
36
37
38
39
40
# File 'lib/em/protocols/zmq2/connection.rb', line 34

def unbind
  self.notify_when_free= false
  if @peer_identity
    @socket.unregister_peer(@peer_identity)
  end
  @socket.not_connected(self)
end