/**
     * Helper method to get the contents of the visitor message, save the image, and save the event
     *
     * @param msg
     */
    private void saveVisitor(StateDeviceProtos.StateDeviceMessage msg) {
      Log.i(TAG, "Logging Event");
      Visitor visitor = new Visitor();
      Long time = System.currentTimeMillis();
      ByteString data = msg.getData();
      String filename = "visitor" + System.currentTimeMillis() + ".jpg";
      visitor.setImagePath(filename);
      File imageDirectory = new File(mContext.getFilesDir() + ConstantManager.IMAGE_DIR);

      // create the image directory if it doesn't exist
      if (!imageDirectory.exists()) {
        Log.i(TAG, "Directory being created? " + imageDirectory.mkdirs());
      }

      // save the image file
      File image = new File(imageDirectory, filename);
      try {
        if (!image.exists()) {
          Log.i(TAG, "File being created? " + image.createNewFile());
        }
        FileOutputStream fos = new FileOutputStream(image, true);
        fos.write(data.toByteArray());
        fos.close();
      } catch (IOException e) {
        e.printStackTrace();
      }

      // Log the visitor
      visitor.setTime(time);
      visitor.setLocation(msg.getName());
      VisitorLog.logVisitor(visitor, mContext);
    }