module MimudServer
@@client_list = [] # This is an array containing socket objects.
@@command_table = {} # This is a hash containing commands.
def post_init
# Notifies the admin that a new player connected.
# This should probably be replaced with a logging
# system.
puts "A new player has connected."
# Odd? It appends a new player object to the new
# connection or "socket".
self.instance_variable_set(:@player, Player.new)
# This adds the new connection into our list of
# clients.
@@client_list.push self
send_data("Please enter your name: ")
end
def receive_data(data)
# Parses any input we receive from the player
parse_input(data)
end
def unbind
# Let's us know when someone has disconnected.
puts "#{@player.name} has disconnected."
@@client_list.each do |c|
next if c != self
@@client_list.delete c
end
end
# Returns a reference to the socket's @player object.
def get_player
return @player
end
end