appendFeedEntry static method

Future<FeedFrameResponse> appendFeedEntry(
  1. P2PStream stream, {
  2. required PeerId ownerPeerId,
  3. required String path,
  4. required Uint8List content,
  5. String? entryType,
})

Append an entry to a feed

Implementation

static Future<FeedFrameResponse> appendFeedEntry(
  P2PStream stream, {
  required PeerId ownerPeerId,
  required String path,
  required Uint8List content,
  String? entryType,
}) async {
  try {
    final requestBytes = FeedFrame.encodeRequest(
      operation: 'APPEND',
      ownerPeerId: ownerPeerId,
      path: path,
      body: content,
      entryType: entryType,
    );

    await _writeFrameStatic(stream, requestBytes);
    final responseBytes = await _readFrameStatic(stream);
    return FeedFrame.decodeResponse(responseBytes);
  } catch (e, stackTrace) {
    _logger.severe('Error appending feed entry: $e', e, stackTrace);
    rethrow;
  }
}