Class: Blur::Network::Connection
- Inherits:
-
EM::Protocols::LineAndTextProtocol
- Object
- EM::Protocols::LineAndTextProtocol
- Blur::Network::Connection
- Defined in:
- library/blur/network/connection.rb
Overview
The Connection class inherits the LineAndText protocol bundled with the eventmachine library.
It merely acts as a receiving handler for all messages eventmachine throws at it through its lifetime.
Instance Method Summary (collapse)
-
- (Object) connection_completed
Called once the connection is finally established.
-
- (Boolean) established?
Check whether or not connection is established.
-
- (Connection) initialize(network)
constructor
EventMachine instantiates this class, and then sends event messages to that instance.
-
- (Object) post_init
Called when a new connection is being set up, all we're going to use it for is to enable SSL/TLS on our connection.
-
- (Object) receive_line(line)
Called when a line was received, the connection sends it to the network delegate which then sends it to the client.
-
- (Object) ssl_handshake_completed
Called when the SSL handshake was completed with the remote server, the reason we tell the network that we're connected here is to ensure that the SSL/TLS encryption succeeded before we start talking nonsense to the server.
-
- (Object) unbind
Called just as the connection is being terminated, either by remote or local.
Constructor Details
- (Connection) initialize(network)
EventMachine instantiates this class, and then sends event messages to that instance.
19 20 21 22 23 24 |
# File 'library/blur/network/connection.rb', line 19 def initialize network @network = network @connected = false super end |
Instance Method Details
- (Object) connection_completed
Called once the connection is finally established.
48 49 50 |
# File 'library/blur/network/connection.rb', line 48 def connection_completed @network.connected! unless @network.secure? end |
- (Boolean) established?
Check whether or not connection is established.
15 |
# File 'library/blur/network/connection.rb', line 15 def established?; @connected == true end |
- (Object) post_init
Called when a new connection is being set up, all we're going to use it for is to enable SSL/TLS on our connection.
28 29 30 |
# File 'library/blur/network/connection.rb', line 28 def post_init start_tls if @network.secure? end |
- (Object) receive_line(line)
Called when a line was received, the connection sends it to the network delegate which then sends it to the client.
34 35 36 37 |
# File 'library/blur/network/connection.rb', line 34 def receive_line line command = Command.parse line @network.got_command command end |
- (Object) ssl_handshake_completed
Called when the SSL handshake was completed with the remote server, the reason we tell the network that we're connected here is to ensure that the SSL/TLS encryption succeeded before we start talking nonsense to the server.
43 44 45 |
# File 'library/blur/network/connection.rb', line 43 def ssl_handshake_completed connected! end |
- (Object) unbind
Called just as the connection is being terminated, either by remote or local.
54 55 56 57 58 |
# File 'library/blur/network/connection.rb', line 54 def unbind @connected = false super end |