# File lib/core/account.rb, line 62
  def update(msg)
    case msg
    # Handle disconnection from server
    # Note that publishing a :quit event (see #disconnect) will return a
    #  :disconnected event when server has closed the connection.
    # Guest accounts and characters are deleted here.
    when :disconnected
      @conn = nil
      unsubscribe_all
      Engine.instance.db.makeswap(id)
      if @character
        world.connected_characters.delete(@character.id)
        world.connected_characters.each do |pid|
          add_event(@character.id,pid,:show,"#{name} has disconnected.")
        end
        Engine.instance.db.makeswap(@character.id)
        @character.account = nil
        if @character.name =~ /Guest/i
          world.all_characters.delete(@character.id)
          delete_object(@character.id)
        end
        @character = nil
      end
      if name =~ /Guest/i
        world.all_accounts.delete(id)
        delete_object(id)
      end
    # Issued when a NAWS event occurs
    # Currently this clears and resets the screen.  Ideally it should attempt
    # to redraw it.
    when :termsize
      @termsize = @conn.query(:termsize)
      if vtsupport?
        publish("[home #{@termsize[1]},1][clearline][cursave]" +
          "[home 1,1][scrreset][clear][scrreg 1,#{@termsize[1]-3}][currest]")
      end
    # Negotiation with client done.  Start talking to it.
    when :initdone
      @echo = @conn.query(:echo)
      @termsize = @conn.query(:termsize)
      @terminal = @conn.query(:terminal)
      if vtsupport?
        publish("[home #{@termsize[1]},1][clearline][cursave]" +
          "[home 1,1][scrreset][clear][scrreg 1,#{@termsize[1]-3}][currest]")
        sendmsg(LOGO)
      end
      sendmsg(BANNER)
      sendmsg(append_echo("login> "))
      @mode = :name
    # This is a message from our user
    when String
      parse_messages(msg)
    else
      log.error "Account#update unknown message - #{msg.inspect}"
    end
  rescue
    # We squash and print out all exceptions here.  There is no reason to
    # throw these back at the Connection.
    log.error $!
  end