Class: EatMySoul::Netsoul
- Inherits:
-
EM::Connection
- Object
- EM::Connection
- EatMySoul::Netsoul
- Defined in:
- lib/eatmysoul.rb
Constant Summary collapse
- ERROR =
0
- NOT_CONNECTED =
1
- CONNECTED =
2
- AUTHING =
3
- AUTHACK =
4
- AUTHED =
5
Instance Attribute Summary collapse
-
#last_ping ⇒ Object
readonly
Returns the value of attribute last_ping.
Instance Method Summary collapse
-
#initialize(settings) ⇒ Netsoul
constructor
A new instance of Netsoul.
- #post_init ⇒ Object
- #receive_data(data) ⇒ Object
- #unbind ⇒ Object
Constructor Details
#initialize(settings) ⇒ Netsoul
Returns a new instance of Netsoul.
130 131 132 133 134 135 |
# File 'lib/eatmysoul.rb', line 130 def initialize(settings) @o = settings @status = NOT_CONNECTED @last_ping = Time.now Manager.instance.active_connection = self end |
Instance Attribute Details
#last_ping ⇒ Object (readonly)
Returns the value of attribute last_ping.
128 129 130 |
# File 'lib/eatmysoul.rb', line 128 def last_ping @last_ping end |
Instance Method Details
#post_init ⇒ Object
137 138 139 |
# File 'lib/eatmysoul.rb', line 137 def post_init @status = CONNECTED end |
#receive_data(data) ⇒ Object
141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'lib/eatmysoul.rb', line 141 def receive_data(data) @o.logger.debug "Read from server \"#{data.chomp}\"" if @status == CONNECTED auth_start data elsif @status == AUTHING auth data elsif @status == AUTHACK auth_ack data elsif @status == AUTHED ping (data) elsif @status == ERROR @o.logger.warn "Receiving data, but connection is in ERROR state" end end |