Class: Empp::MsgConnect
Instance Attribute Summary
Attributes inherited from EmppBase
#command_id, #sequence_id, #total_length
Instance Method Summary collapse
-
#initialize(accountId, password) ⇒ MsgConnect
constructor
A new instance of MsgConnect.
- #package ⇒ Object
Constructor Details
#initialize(accountId, password) ⇒ MsgConnect
Returns a new instance of MsgConnect.
13 14 15 16 17 18 19 20 |
# File 'lib/empp/msg_connect.rb', line 13 def initialize(accountId, password) @accountId = accountId @password = password @total_length = 12 + 21 + 16 + 1 + 4 @command_id = Constants::EMPPCONNECT setSequenceId end |
Instance Method Details
#package ⇒ Object
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/empp/msg_connect.rb', line 22 def package buf = Utils::ByteBuffer.new # add header buf.append_uint_be(@total_length) buf.append_uint_be(@command_id) buf.append_uint_be(@sequence_id) # 21 bytes accountId act_id = @accountId.to_s buf.append_string( act_id.ljust(21, "\0") ) = Utils::Utils.getTimestampStr(Time.now) # 16 bytes AuthenticatorSource authSource = @accountId.to_s + ''.rjust(9, "\0") + @password + buf.append_string( MD5.digest(authSource) ) # 1 byte version, fixed buf.append_string( Utils::Utils.getVersion ) # 4 bytes timestamp buf.append_string( Utils::Utils.getUintBe(.to_i) ) buf.data end |