Skip to content

There is no way to reject receiving binary data / stream or terminate it #125

@andres-kovalev

Description

@andres-kovalev

As mentioned in the title - there is no way:

  • to reject receiving an action payload (for instance, peer might want to reject huge blobs)
  • cancel any ongoing action transmission (for instance, peer might want to cancel ongoing file transmission if it's too big or sent by mistake)

Is it by design?

P.S. The first issue can be solved by additional pair of actions to perform a handshake:

const [sendFile, onFileReceived] = room.makeAction('file');
const [ask, onRequest] = room.makeAction('request');
const [respond, onResponse] = room.makeAction('response');

onRequest((request, peerId) => {
  const shouldReject = banned.has(peerId) || request.size > MAX_SIZE;

  respond({ reqId: request.id, result: shouldReject ? 'reject' : 'accept' }, peerId);
});

onResponse((response, peerId) => {
  if (response.result === 'accept') sendFile(requestsMap[response.reqId].file, peerId);
  else if (response.result === 'reject') requestsMap.delete(response.reqId);
});

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions