Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 4 additions & 3 deletions src/AudioMixer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import AudioOutput from "./domain/audio/AudioOutput";
import AudioClient from "./domain/audio-client/AudioClient";
import NodeType from "./domain/networking/NodeType";
import ContextManager from "./domain/shared/ContextManager";
import Log from "./domain/shared/Log";


/*@sdkdoc
Expand Down Expand Up @@ -109,13 +110,13 @@ class AudioMixer extends AssignmentClient {

set audioInput(audioInput: MediaStream | null) {
if (audioInput !== null && !(audioInput instanceof MediaStream)) {
console.error("Tried to set an invalid AudioMixer.audioInput value!");
Log.error("Tried to set an invalid AudioMixer.audioInput value!", "audio");
return;
}

void this.#_audioClient.switchInputDevice(audioInput).then((success) => {
if (!success) {
console.warn("Could not set the audio input.");
Log.warning("Could not set the audio input.", "audio");
}
});
}
Expand All @@ -126,7 +127,7 @@ class AudioMixer extends AssignmentClient {

set inputMuted(inputMuted: boolean) {
if (typeof inputMuted !== "boolean") {
console.error("Tried to set an invalid AudioMixer.inputMuted value!");
Log.error("Tried to set an invalid AudioMixer.inputMuted value!", "audio");
return;
}
this.#_audioClient.setMuted(inputMuted);
Expand Down
19 changes: 10 additions & 9 deletions src/DomainServer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import Node from "./domain/networking/Node";
import NodeList from "./domain/networking/NodeList";
import NodeType from "./domain/networking/NodeType";
import ContextManager from "./domain/shared/ContextManager";
import Log from "./domain/shared/Log";
import SignalEmitter, { Signal } from "./domain/shared/SignalEmitter";
import Uuid from "./domain/shared/Uuid";

Expand Down Expand Up @@ -219,7 +220,7 @@ class DomainServer {
if (typeof callback === "function" || callback === null) {
this.#_onStateChanged = callback;
} else {
console.error("ERROR: DomainServer.onStateChanged callback not a function or null!");
Log.error("ERROR: DomainServer.onStateChanged callback not a function or null!");
this.#_onStateChanged = null;
}
}
Expand Down Expand Up @@ -264,7 +265,7 @@ class DomainServer {
if (typeof location === "string") {
this.#_location = location.trim();
} else {
console.error("ERROR: DomainServer.connect() location parameter not a string!");
Log.error("ERROR: DomainServer.connect() location parameter not a string!");
this.#_location = "";
}

Expand Down Expand Up @@ -316,7 +317,7 @@ class DomainServer {
#setState(state: ConnectionState, info = ""): void {
const hasStateChanged = state !== this.#_state;
if (this.#_DEBUG && !hasStateChanged) {
console.warn("DomainServer: State hasn't changed.");
Log.warning("DomainServer: State hasn't changed.");
}

this.#_state = state;
Expand Down Expand Up @@ -366,7 +367,7 @@ class DomainServer {
#nodeAdded = (node: Node): void => {
// C++ void Application:: nodeAdded(Node* node)
if (node.getType() === NodeType.EntityServer) {
console.warn("DomainServer: EntityServer support implemented!");
Log.warning("DomainServer: EntityServer support implemented!");

// WEBRTC TODO: Address further code - for EntityServer node.

Expand All @@ -381,17 +382,17 @@ class DomainServer {
// AudioMixer node is handled in AudioMixer.ts.

if (nodeType === NodeType.AssetServer) {
console.warn("DomainServer: AssetServer support not implemented!");
Log.warning("DomainServer: AssetServer support not implemented!");

// WEBRTC TODO: Address further code - for AssetServer node.

} else if (nodeType === NodeType.EntityServer) {
console.warn("DomainServer: EntityServer support not implemented!");
Log.warning("DomainServer: EntityServer support not implemented!");

// WEBRTC TODO: Address further code - for EntityServer node.

} else if (nodeType === NodeType.AvatarMixer) {
console.warn("DomainServer: AvatarMixer support not implemented!");
Log.warning("DomainServer: AvatarMixer support not implemented!");

// WEBRTC TODO: Address further code - for AvatarMixer node.

Expand All @@ -408,12 +409,12 @@ class DomainServer {
// AudioMixer node is handled in AudioMixer.ts.

if (nodeType === NodeType.EntityServer) {
console.warn("DomainServer: EntityServer support not implemented!");
Log.warning("DomainServer: EntityServer support not implemented!");

// WEBRTC TODO: Address further code - for EntityServer node.

} else if (nodeType === NodeType.AssetServer) {
console.warn("DomainServer: AssetServer support not implemented!");
Log.warning("DomainServer: AssetServer support not implemented!");

// WEBRTC TODO: Address further code - for AssetServer node.

Expand Down
9 changes: 5 additions & 4 deletions src/MessageMixer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ import AssignmentClient from "./domain/AssignmentClient";
import MessagesClient from "./domain/networking/MessagesClient";
import NodeType from "./domain/networking/NodeType";
import { Signal } from "./domain/shared/SignalEmitter";
import Log from "./domain/shared/Log";


/*@sdkdoc
Expand Down Expand Up @@ -97,7 +98,7 @@ class MessageMixer extends AssignmentClient {
*/
subscribe(channel: string): void {
if (typeof channel !== "string" || channel.length === 0) {
console.error("[MessageMixer] subscribe() called with invalid channel value!");
Log.error("subscribe() called with invalid channel value!", "MessageMixer");
return;
}

Expand All @@ -111,7 +112,7 @@ class MessageMixer extends AssignmentClient {
*/
unsubscribe(channel: string): void {
if (typeof channel !== "string" || channel.length === 0) {
console.error("[MessageMixer] unsubscribe() called with invalid channel value!");
Log.error("unsubscribe() called with invalid channel value!", "MessageMixer");
return;
}

Expand All @@ -133,7 +134,7 @@ class MessageMixer extends AssignmentClient {
// @ts-ignore
sendMessage(channel: string, message: string, localOnly = false): void { // eslint-disable-line
if (typeof channel !== "string" || typeof message !== "string" || typeof localOnly !== "boolean") {
console.error("[MessageMixer] sendMessage() called with invalid channel parameters!");
Log.error("sendMessage() called with invalid channel parameters!", "MessageMixer");
return;
}

Expand All @@ -156,7 +157,7 @@ class MessageMixer extends AssignmentClient {
// @ts-ignore
sendData(channel: string, data: ArrayBuffer, localOnly = false): void { // eslint-disable-line
if (typeof channel !== "string" || !(data instanceof ArrayBuffer) || typeof localOnly !== "boolean") {
console.error("[MessageMixer] sendData() called with invalid channel parameters!");
Log.error("sendData() called with invalid channel parameters!", "MessageMixer");
return;
}

Expand Down
3 changes: 2 additions & 1 deletion src/domain/AssignmentClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import Node from "./networking/Node";
import NodeList from "./networking/NodeList";
import { NodeTypeValue } from "./networking/NodeType";
import ContextManager from "./shared/ContextManager";
import Log from "./shared/Log";


/*@devdoc
Expand Down Expand Up @@ -152,7 +153,7 @@ class AssignmentClient {
if (typeof callback === "function" || callback === null) {
this.#_onStateChanged = callback;
} else {
console.error("ERROR: AssignmentClient.onStateChanged callback not a function or null!");
Log.error("AssignmentClient.onStateChanged callback not a function or null!");
this.#_onStateChanged = null;
}
}
Expand Down
18 changes: 10 additions & 8 deletions src/domain/audio-client/AudioClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import PacketScribe from "../networking/packets/PacketScribe";
import PacketType, { PacketTypeValue } from "../networking/udt/PacketHeaders";
import assert from "../shared/assert";
import ContextManager from "../shared/ContextManager";
import Log, { LogLevel } from "../shared/Log";


/*@devdoc
Expand Down Expand Up @@ -185,10 +186,10 @@ class AudioClient {
? inputDeviceAudioSettings.echoCancellation
: false;
}
console.log("[audioclient] Input device info:", inputDeviceAudioSettings
Log.message("Input device info:" + (inputDeviceAudioSettings
? `${deviceName}, ${channelCount} channels, ${sampleRate}Hz, ${sampleSize} bits, `
+ `echo cancellation ${echoCancellation ? "on" : "off"}`
: null);
: ""), "audioclient");

let supportedFormat = false;

Expand All @@ -210,7 +211,7 @@ class AudioClient {
// WEBRTC TODO: Address further C++.

if (isShutdownRequest) {
console.log("[audioclient] The audio input device has shut down.");
Log.message("The audio input device has shut down.", "audioclient");
return true;
}

Expand All @@ -231,12 +232,12 @@ class AudioClient {
this.#_audioInput.readyRead.connect(this.#handleMicAudioInput);
supportedFormat = true;
} else {
console.error("[audioclient] Error starting audio input -", this.#_audioInput.errorString());
Log.error(`Error starting audio input - ${this.#_audioInput.errorString()}`, "audioclient");
}
}

if (!supportedFormat) {
console.log("[audioclient] Audio input device is not available, using dummy input.");
Log.message("Audio input device is not available, using dummy input.", "audioclient");

// WEBRTC TODO: Address further C++.

Expand Down Expand Up @@ -369,7 +370,8 @@ class AudioClient {

this.#_selectedCodecName = selectedCodecName;

console.log("[audioclient] Selected codec:", this.#_selectedCodecName, "; Is stereo input:", this.#_isStereoInput);
Log.message(`Selected codec: ${this.#_selectedCodecName} ; Is stereo input: ${this.#_isStereoInput.toString()}`,
"audioclient");

// WEBRTC TODO: Address further C++ code.

Expand Down Expand Up @@ -406,7 +408,7 @@ class AudioClient {
#processStreamStatsPacket = (message: ReceivedMessage, sendingNode: Node | null): void => { // eslint-disable-line
// C++ void AudioIOStats::processStreamStatsPacket(ReceivedMessage*, Node* sendingNode)

console.warn("AudioClient: AudioStreamStats packet not processed.");
Log.once(LogLevel.WARNING, "AudioClient: AudioStreamStats packet not processed.", "audioclient");

// WEBRTC TODO: Address further C++ code.

Expand All @@ -418,7 +420,7 @@ class AudioClient {
#handleAudioEnvironmentDataPacket = (message: ReceivedMessage): void => { // eslint-disable-line
// C++ void handleAudioEnvironmentDataPacket(ReceivedMessage* message)

console.warn("AudioClient: AudioEnvironment packet not processed.");
Log.once(LogLevel.WARNING, "AudioClient: AudioEnvironment packet not processed.", "audioclient");

// WEBRTC TODO: Address further C++ code.

Expand Down
7 changes: 4 additions & 3 deletions src/domain/audio/AudioInput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import AudioConstants from "../audio/AudioConstants";
import assert from "../shared/assert";
import Log from "../shared/Log";
import SignalEmitter, { Signal } from "../shared/SignalEmitter";

// eslint-disable-next-line
Expand Down Expand Up @@ -50,7 +51,7 @@ class AudioInput {
set audioInput(audioInput: MediaStream | null) {
// C++ N/A
if (audioInput && this.#_isStarted) {
console.error("Cannot set the audio input while it is running!");
Log.error("Cannot set the audio input while it is running!", "audio");
return;
}

Expand Down Expand Up @@ -200,7 +201,7 @@ class AudioInput {
}
if (frame === undefined) {
this.#_errorString = "Unexpected read of empty audio input buffer!";
console.error(this.#_errorString);
Log.error(this.#_errorString, "audio");
return null;
}
return frame;
Expand Down Expand Up @@ -268,7 +269,7 @@ class AudioInput {
// Audio worklet.
if (!this.#_audioContext.audioWorklet) {
this.#_errorString = "Cannot set up audio input stream. App may not be being served via HTTPS or from localhost.";
console.error(this.#_errorString);
Log.error(this.#_errorString, "audio");
return false;
}
await this.#_audioContext.audioWorklet.addModule(audioInputProcessorURL);
Expand Down
3 changes: 2 additions & 1 deletion src/domain/audio/AudioOutput.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

import assert from "../shared/assert";
import AudioConstants from "../audio/AudioConstants";
import Log from "../shared/Log";

// eslint-disable-next-line
// @ts-ignore
Expand Down Expand Up @@ -159,7 +160,7 @@ class AudioOutput {

// Audio worklet.
if (!this.#_audioContext.audioWorklet) {
console.error("Cannot set up audio output stream. App may not be being served via HTTPS or from localhost.");
Log.error("Cannot set up audio output stream. App may not be being served via HTTPS or from localhost.", "audio");
return;
}
await this.#_audioContext.audioWorklet.addModule(audioOutputProcessorURL);
Expand Down
8 changes: 5 additions & 3 deletions src/domain/audio/InboundAudioStream.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import { SilentAudioFrameDetails } from "../networking/packets/SilentAudioFrame"
import PacketType from "../networking/udt/PacketHeaders";
import UDT from "../networking/udt/UDT";
import ContextManager from "../shared/ContextManager";
import Log, { LogLevel } from "../shared/Log";


/*@devdoc
Expand Down Expand Up @@ -86,7 +87,7 @@ class InboundAudioStream {
} else {

// WEBRTC TODO: Address further C++ code.
console.warn("Codec mismatch not handled.");
Log.warning("Codec mismatch not handled.", "audio");

}
}
Expand Down Expand Up @@ -124,7 +125,8 @@ class InboundAudioStream {
// C++ int writeDroppableSilentFrames(int silentFrames)

// WEBRTC TODO: Address further C++ code.
console.warn("InboundAudioStream.#writeDroppableSilentFrames() not implemented. Frames:", silentFrames);
Log.once(LogLevel.WARNING, `InboundAudioStream.#writeDroppableSilentFrames() not implemented. Frames: ${silentFrames}`,
"audio");

}

Expand All @@ -136,7 +138,7 @@ class InboundAudioStream {
if (this.#_decoder) {

// WEBRTC TODO: Address further C++ code.
console.warn("Codec support not implemented.", this.#_selectedCodecName);
Log.once(LogLevel.WARNING, `Codec support not implemented. ${this.#_selectedCodecName}`, "audio");
decodedBuffer = new Int16Array();

} else {
Expand Down
11 changes: 6 additions & 5 deletions src/domain/networking/DomainHandler.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import SignalEmitter, { Signal } from "../shared/SignalEmitter";
import Uuid from "../shared/Uuid";
import PacketScribe from "./packets/PacketScribe";
import ReceivedMessage from "./ReceivedMessage";
import Log from "../shared/Log";


/*@devdoc
Expand Down Expand Up @@ -253,8 +254,8 @@ class DomainHandler {
// WEBRTC TODO: Should C++ clear _domainConnectionRefusals also?
this.#_domainConnectionRefusals.clear(); // Re-report any refusals if retry connecting to the same domain.

console.log("[networking] Disconnecting from domain server.");
console.log("[networking] REASON:", reason);
Log.message("Disconnecting from domain server.", "networking");
Log.message(`REASON: ${reason}`, "networking");
this.setIsConnected(false, forceDisconnect);
}

Expand All @@ -279,7 +280,7 @@ class DomainHandler {
*/
softReset(reason: string): void {
// C++ void softReset(QString reason) {
console.log("[networking] Resetting current domain connection information.");
Log.message("Resetting current domain connection information.", "networking");
this.disconnect(reason);

// WEBRTC TODO: Address further C++ code.
Expand All @@ -298,8 +299,8 @@ class DomainHandler {

const info = PacketScribe.DomainConnectionDenied.read(message.getMessage());
const sanitizedExtraInfo = info.extraInfo.toLowerCase().startsWith("http") ? "" : info.extraInfo;
console.warn("[networking] The domain-server denied a connection request: ", info.reasonMessage, "extraInfo:",
sanitizedExtraInfo);
Log.warning(`The domain-server denied a connection request: ${info.reasonMessage} extraInfo: ${sanitizedExtraInfo}`,
"networking");

if (!this.#_domainConnectionRefusals.has(info.reasonMessage)) {
this.#_domainConnectionRefusals.add(info.reasonMessage);
Expand Down
3 changes: 2 additions & 1 deletion src/domain/networking/HMACAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
import Uuid from "../shared/Uuid";
import UDT from "./udt/UDT";
import "../shared/DataViewExtensions";
import Log from "../shared/Log";

import CryptoJS from "crypto-js";

Expand Down Expand Up @@ -85,7 +86,7 @@ class HMACAuth {

// Vircadia only uses MD5.
if (authMethod !== HMACAuth.MD5) {
console.error("HMACAuth method not supported:", authMethod);
Log.error(`HMACAuth method not supported: ${authMethod}`);
}

this.#_keyWordArray = CryptoJS.lib.WordArray.create([]);
Expand Down
Loading