Home > rainway-sdk > RainwayStream > setOutgoingInputFilter
RainwayStream.setOutgoingInputFilter() method
Set a filter on inputs we send to this stream.
This filter is called when this peer wants to send keyboard, mouse, gamepad, etc. input to a remote peer.
Only inputs of types enabled by the stream's InputLevel make it into this filter.
Returning true
will send the input request to the remote peer. The remote peer may have a further filter on incoming inputs.
Returning false
will prevent the input request from being sent. This should not be used for security-sensitive filtering like Alt-Tab prevention; prefer an incomingInputFilter
on the host.
This outgoing filter is more useful for replacing certain keys with application logic. For example, to make the "Q" key send a Data Channel message instead:
myStream.setOutgoingInputFilter((input, heldKeys) => {
if (input.type === "keyboard" && input.key === VirtualKey.Q) {
// Block the input, but send a message instead.
if (input.action === KeyboardAction.Down) {
stream.host.send(makeCoolRequest());
}
return false;
}
// Pass everything else through unchanged.
return true;
});
The default behavior is to pass through all inputs, equivalent to (input, heldKeys) => true
.
Signature:
setOutgoingInputFilter(filter: (input: OutgoingInput, heldKeys: HeldKeys) => boolean): void;
Parameters
Parameter | Type | Description |
---|---|---|
filter | (input: OutgoingInput, heldKeys: HeldKeys) => boolean |
Returns:
void