Class: Mysql::ServerProtocol
- Defined in:
- lib/nose/proxy/mysql.rb
Overview
Simple class which doesn’t do connection setup
Instance Method Summary collapse
-
#authenticate ⇒ Object
Perform authentication.
-
#error(errno, message) ⇒ Object
Send an error message with the given number and text.
-
#initialize(socket) ⇒ ServerProtocol
constructor
A new instance of ServerProtocol.
-
#process_command(&block) ⇒ Object
Process a single incoming command.
Constructor Details
#initialize(socket) ⇒ ServerProtocol
Returns a new instance of ServerProtocol.
93 94 95 96 |
# File 'lib/nose/proxy/mysql.rb', line 93 def initialize(socket) # We need a much simpler initialization than the default class @sock = socket end |
Instance Method Details
#authenticate ⇒ Object
Perform authentication
99 100 101 102 103 104 |
# File 'lib/nose/proxy/mysql.rb', line 99 def authenticate reset write InitialPacket.serialize AuthenticationPacket.parse read # TODO: Check auth write ResultPacket.serialize 0 end |
#error(errno, message) ⇒ Object
Send an error message with the given number and text
107 108 109 |
# File 'lib/nose/proxy/mysql.rb', line 107 def error(errno, ) write ErrorPacket.serialize errno, end |
#process_command(&block) ⇒ Object
Process a single incoming command
112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 |
# File 'lib/nose/proxy/mysql.rb', line 112 def process_command(&block) reset pkt = read command = pkt.utiny case command when COM_QUIT # Stop processing because the client left return when COM_QUERY process_query pkt.to_s, &block when COM_PING write ResultPacket.serialize 0 else # Return error for invalid commands protocol.error ::Mysql::ServerError::ER_NOT_SUPPORTED_YET, 'Command not supported' end end |