Skip to content

Commit fefd510

Browse files
committed
refactor: run npm run format
1 parent 59a96c8 commit fefd510

7 files changed

Lines changed: 28 additions & 36 deletions

File tree

examples/rpc/rpc-demo.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,9 @@ const registerReceiverMethods = async (greetersRoom: Room, mathGeniusRoom: Room)
9696
'exchanging-long-info',
9797
// eslint-disable-next-line @typescript-eslint/no-unused-vars
9898
async (data: RpcInvocationData) => {
99-
console.log(`[Greeter] ${data.callerIdentity} has arrived and said that its long info is "${data.payload}"`);
99+
console.log(
100+
`[Greeter] ${data.callerIdentity} has arrived and said that its long info is "${data.payload}"`,
101+
);
100102
await new Promise((resolve) => setTimeout(resolve, 2000));
101103
return new Array<string>(10_000).fill('Y').join('');
102104
},
@@ -154,7 +156,7 @@ const performGreeting = async (room: Room): Promise<void> => {
154156
};
155157

156158
const performSendVeryLongInfo = async (room: Room): Promise<void> => {
157-
console.log("[Caller] Sending the greeter a very long message");
159+
console.log('[Caller] Sending the greeter a very long message');
158160
try {
159161
const response = await room.localParticipant.performRpc({
160162
destinationIdentity: 'greeter',

src/room/Room.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,6 +45,7 @@ import type {
4545
} from '../options';
4646
import TypedPromise from '../utils/TypedPromise';
4747
import { getBrowser } from '../utils/browserParser';
48+
import { CLIENT_PROTOCOL_DEFAULT } from '../version';
4849
import { BackOffStrategy } from './BackOffStrategy';
4950
import DeviceManager from './DeviceManager';
5051
import RTCEngine from './RTCEngine';
@@ -120,7 +121,6 @@ import {
120121
unpackStreamId,
121122
unwrapConstraint,
122123
} from './utils';
123-
import { CLIENT_PROTOCOL_DEFAULT } from '../version';
124124

125125
export enum ConnectionState {
126126
Disconnected = 'disconnected',
@@ -2260,9 +2260,9 @@ class Room extends (EventEmitter as new () => TypedEmitter<RoomEventCallbacks>)
22602260
}
22612261
}
22622262

2263-
private getRemoteParticipantClientProtocol = (identity: Participant["identity"]) => {
2263+
private getRemoteParticipantClientProtocol = (identity: Participant['identity']) => {
22642264
return this.remoteParticipants.get(identity)?.clientProtocol ?? CLIENT_PROTOCOL_DEFAULT;
2265-
}
2265+
};
22662266

22672267
private registerRpcDataStreamHandler() {
22682268
this.incomingDataStreamManager.registerByteStreamHandler(

src/room/participant/RemoteParticipant.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ import type {
55
UpdateTrackSettings,
66
} from '@livekit/protocol';
77
import type { SignalClient } from '../../api/SignalClient';
8+
import { CLIENT_PROTOCOL_DEFAULT } from '../../version';
89
import { ParticipantEvent, TrackEvent } from '../events';
910
import RemoteAudioTrack from '../track/RemoteAudioTrack';
1011
import type RemoteTrack from '../track/RemoteTrack';
@@ -19,7 +20,6 @@ import type { LoggerOptions } from '../types';
1920
import { isAudioTrack, isRemoteTrack } from '../utils';
2021
import Participant, { ParticipantKind } from './Participant';
2122
import type { ParticipantEventCallbacks } from './Participant';
22-
import { CLIENT_PROTOCOL_DEFAULT } from '../../version';
2323

2424
export default class RemoteParticipant extends Participant {
2525
audioTrackPublications: Map<string, RemoteTrackPublication>;

src/room/rpc/RpcClientManager.ts

Lines changed: 11 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,15 @@
11
// SPDX-FileCopyrightText: 2026 LiveKit, Inc.
22
//
33
// SPDX-License-Identifier: Apache-2.0
4-
import {
5-
DataPacket,
6-
DataPacket_Kind,
7-
RpcRequest,
8-
} from '@livekit/protocol';
4+
import { DataPacket, DataPacket_Kind, RpcRequest } from '@livekit/protocol';
95
import { type StructuredLogger } from '../../logger';
6+
import { CLIENT_PROTOCOL_GZIP_RPC } from '../../version';
107
import type RTCEngine from '../RTCEngine';
8+
import type { ByteStreamReader } from '../data-stream/incoming/StreamReader';
119
import type OutgoingDataStreamManager from '../data-stream/outgoing/OutgoingDataStreamManager';
10+
import { EngineEvent } from '../events';
1211
import type Participant from '../participant/Participant';
1312
import { Future, compareVersions } from '../utils';
14-
import type { ByteStreamReader } from '../data-stream/incoming/StreamReader';
1513
import {
1614
DATA_STREAM_MIN_BYTES,
1715
MAX_LEGACY_PAYLOAD_BYTES,
@@ -27,8 +25,6 @@ import {
2725
gzipDecompress,
2826
gzipDecompressFromReader,
2927
} from './utils';
30-
import { CLIENT_PROTOCOL_GZIP_RPC } from '../../version';
31-
import { EngineEvent } from '../events';
3228

3329
/**
3430
* Manages the client (caller) side of RPC: sending requests, tracking pending
@@ -49,7 +45,7 @@ export default class RpcClientManager {
4945
private pendingResponses = new Map<
5046
string /* request id */,
5147
{
52-
completionFuture: Future<string, RpcError>,
48+
completionFuture: Future<string, RpcError>;
5349
participantIdentity: string;
5450
}
5551
>();
@@ -276,7 +272,9 @@ export default class RpcClientManager {
276272
}
277273

278274
default: {
279-
this.log.warn(`Error handling RPC response data packet: unknown rpcResponse.value.case found (${rpcResponse.value.case})`);
275+
this.log.warn(
276+
`Error handling RPC response data packet: unknown rpcResponse.value.case found (${rpcResponse.value.case})`,
277+
);
280278
return false;
281279
}
282280
}
@@ -303,10 +301,7 @@ export default class RpcClientManager {
303301
* Handle an incoming byte stream containing an RPC response payload.
304302
* Decompresses the stream and resolves/rejects the pending data stream future.
305303
*/
306-
async handleIncomingDataStream(
307-
reader: ByteStreamReader,
308-
responseId: string,
309-
) {
304+
async handleIncomingDataStream(reader: ByteStreamReader, responseId: string) {
310305
let decompressedPayload: string;
311306
try {
312307
decompressedPayload = await gzipDecompressFromReader(reader);
@@ -347,7 +342,8 @@ export default class RpcClientManager {
347342
}
348343
}
349344

350-
for (const [id, { participantIdentity: pendingIdentity, completionFuture }] of this.pendingResponses) {
345+
for (const [id, { participantIdentity: pendingIdentity, completionFuture }] of this
346+
.pendingResponses) {
351347
if (pendingIdentity === participantIdentity) {
352348
completionFuture.reject?.(RpcError.builtIn('RECIPIENT_DISCONNECTED'));
353349
this.pendingResponses.delete(id);

src/room/rpc/RpcServerManager.ts

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -160,10 +160,7 @@ export default class RpcServerManager {
160160
// Large response: create the data stream tagged with the request ID,
161161
// send the RPC response with empty payload, then stream compressed chunks
162162
// for lower TTFB
163-
if (
164-
callerClientProtocol >= CLIENT_PROTOCOL_GZIP_RPC &&
165-
responseBytes > DATA_STREAM_MIN_BYTES
166-
) {
163+
if (callerClientProtocol >= CLIENT_PROTOCOL_GZIP_RPC && responseBytes > DATA_STREAM_MIN_BYTES) {
167164
const writer = await this.outgoingDataStreamManager.streamBytes({
168165
topic: RPC_DATA_STREAM_TOPIC,
169166
destinationIdentities: [callerIdentity],
@@ -205,15 +202,17 @@ export default class RpcServerManager {
205202
*/
206203
async handleIncomingDataStream(
207204
reader: ByteStreamReader,
208-
callerIdentity: Participant["identity"],
209-
dataStreamAttrs: Record<string, string>
205+
callerIdentity: Participant['identity'],
206+
dataStreamAttrs: Record<string, string>,
210207
) {
211208
const requestId = dataStreamAttrs[RPC_REQUEST_ID_ATTR];
212209
const method = dataStreamAttrs[RPC_REQUEST_METHOD_ATTR];
213210
const responseTimeout = parseInt(dataStreamAttrs[RPC_REQUEST_RESPONSE_TIMEOUT_MS_ATTR], 10);
214211

215212
if (!requestId || !method || Number.isNaN(responseTimeout)) {
216-
this.log.warn(`RPC data stream malformed: ${RPC_REQUEST_ID_ATTR} / ${RPC_REQUEST_METHOD_ATTR} / ${RPC_REQUEST_RESPONSE_TIMEOUT_MS_ATTR} not set.`);
213+
this.log.warn(
214+
`RPC data stream malformed: ${RPC_REQUEST_ID_ATTR} / ${RPC_REQUEST_METHOD_ATTR} / ${RPC_REQUEST_RESPONSE_TIMEOUT_MS_ATTR} not set.`,
215+
);
217216
await this.engine.publishRpcResponse(
218217
callerIdentity,
219218
requestId,
@@ -277,10 +276,7 @@ export default class RpcServerManager {
277276

278277
const responseBytes = byteLength(response ?? '');
279278

280-
if (
281-
callerClientProtocol >= CLIENT_PROTOCOL_GZIP_RPC &&
282-
responseBytes > DATA_STREAM_MIN_BYTES
283-
) {
279+
if (callerClientProtocol >= CLIENT_PROTOCOL_GZIP_RPC && responseBytes > DATA_STREAM_MIN_BYTES) {
284280
// Large response: create the data stream tagged with the request ID,
285281
// send the RPC response with empty payload, then stream compressed chunks
286282
// for lower TTFB

src/room/rpc/utils.ts

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -261,9 +261,7 @@ export async function gzipDecompress(data: Uint8Array): Promise<string> {
261261
* into the decompression stream as it arrives rather than buffering first.
262262
* @internal
263263
*/
264-
export async function gzipDecompressFromReader(
265-
reader: AsyncIterable<Uint8Array>,
266-
): Promise<string> {
264+
export async function gzipDecompressFromReader(reader: AsyncIterable<Uint8Array>): Promise<string> {
267265
const ds = new DecompressionStream('gzip');
268266
const dsWriter = ds.writable.getWriter();
269267

src/version.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,5 +7,5 @@ export const CLIENT_PROTOCOL_DEFAULT = 0;
77
export const CLIENT_PROTOCOL_GZIP_RPC = 1;
88

99
/** The client protocol version indicates what level of support that the client has for
10-
* client <-> client api interactions. */
10+
* client <-> client api interactions. */
1111
export const clientProtocol = CLIENT_PROTOCOL_GZIP_RPC;

0 commit comments

Comments
 (0)