Class: UserHandler

Inherits:
Handler
  • Object
show all
Defined in:
lib/handler/user_handler.rb

Instance Method Summary collapse

Instance Method Details

#recv(server, connection, packet) ⇒ Object



2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/handler/user_handler.rb', line 2

def recv(server,connection,packet)
	case packet.id
		when Protocol::REGIST
		when Protocol::UNREGIST
		when Protocol::LOGIN
			rs = connection.db.select("account", "*", "id=#{packet["id"]} and pw=#{paacket["pw"]}")
			row = rs.next
			
			reply = Packet.new
			reply.id = LOGIN_RESULT
			if row == nil
				reply["result"] = nil
			else
				reply["result"] = true
				connection.id = packet["id"]
				connection.mem.push_prefix packet["id"]
			end
			
			rs.close
			connection.send reply
		when Protocol::LOGOUT
	end
end