コード例 #1
0
ファイル: StructrWebSocket.java プロジェクト: hwloh/structr
  @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);
    }
  }
コード例 #2
0
ファイル: StructrWebSocket.java プロジェクト: hwloh/structr
  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);
    }
  }