Exemplo n.º 1
0
  @Override
  public void onWebSocketClose(final int closeCode, final String message) {

    logger.log(
        Level.INFO,
        "Connection closed with closeCode {0} and message {1}",
        new Object[] {closeCode, message});

    final App app = StructrApp.getInstance(securityContext);

    try (final Tx tx = app.tx()) {

      this.session = null;

      syncController.unregisterClient(this);

      // flush and close open uploads
      for (FileUploadHandler upload : uploads.values()) {

        upload.finish();
      }

      tx.success();
      uploads.clear();

    } catch (FrameworkException fex) {

      logger.log(Level.SEVERE, "Error while closing connection", fex);
    }
  }
Exemplo n.º 2
0
  public void handleFileChunk(
      final String uuid,
      final int sequenceNumber,
      final int chunkSize,
      final byte[] data,
      final int chunks)
      throws IOException {

    FileUploadHandler upload = uploads.get(uuid);

    if (upload == null) {

      upload = handleExistingFile(uuid);
    }

    if (upload != null) {

      upload.handleChunk(sequenceNumber, chunkSize, data, chunks);
    }
  }