func NewAuthenticationResponse(packet *network.InboundPacket) *AuthenticationResponse {
	var salt []byte = nil
	var authData []byte = nil

	resultRaw := packet.ReadUInt32()
	result := constants.AuthenticationResult(resultRaw)
	other := packet.ReadRemaining()

	if result == constants.AuthenticationResultCryptPassword || result == constants.AuthenticationResultMD5Password {
		salt = other
	}

	if result == constants.AuthenticationResultGSSContinue {
		authData = other
	}

	return &AuthenticationResponse{result, salt, authData}
}
func NewServerMessageResponse(packet *network.InboundPacket) *ServerMessageResponse {
	messageType := "notice"

	if packet.Type == constants.PacketTypeServerErrorResponse {
		messageType = "error"
	}

	messageFields := make(map[string]string)

	for {
		field := packet.ReadString()
		if field == "" {
			break
		}

		fieldType := string([]byte(field)[0])
		fieldValue := string([]byte(field)[1:])

		messageFields[messageFieldMappings[fieldType]] = fieldValue
	}

	return &ServerMessageResponse{messageType, messageFields}
}
func NewBackendKeyResponse(packet *network.InboundPacket) *BackendKeyResponse {
	pid := packet.ReadUInt32()
	key := packet.ReadUInt32()

	return &BackendKeyResponse{pid, key}
}
func NewParameterStatusResponse(packet *network.InboundPacket) *ParameterStatusResponse {
	key := packet.ReadString()
	value := packet.ReadString()

	return &ParameterStatusResponse{key, value}
}