Skip to content
Draft
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
4 changes: 3 additions & 1 deletion src/apps/components/addserver/runtime.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { AppProcess } from "$ts/apps/process";
import { Server } from "$ts/env";
import { Server, SoundBus } from "$ts/env";
import { ErrorIcon, WarningIcon } from "$ts/images/dialog";
import { GoodStatusIcon } from "$ts/images/status";
import { MessageBox } from "$ts/util/dialog";
Expand Down Expand Up @@ -90,6 +90,7 @@ export class AddServerRuntime extends AppProcess {
if (this.action() === "") this.action.set("callServer");

try {
SoundBus.playSound("arcos.bip");
const response = await axios.get(`/ping`, {
timeout: 3000,
timeoutErrorMessage: "We're offline",
Expand All @@ -98,6 +99,7 @@ export class AddServerRuntime extends AppProcess {
});

if (response.status !== 200) return false;
SoundBus.playSound("arcos.bop");

return true;
} catch {
Expand Down
Binary file added src/assets/audio/bip.wav
Binary file not shown.
Binary file added src/assets/audio/bop.wav
Binary file not shown.
2 changes: 0 additions & 2 deletions src/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ import "./css/main.css";
// CODE EXECUTION STARTS HERE
async function Main() {
const { WaveKernel } = await import("$ts/kernel/wavekernel");

const kernel = new WaveKernel();

window.__DW_STATUS__ = "async Main";
document.querySelector<HTMLDivElement>("#stateLoader")!.innerText = "..";

await kernel._init();
}

Expand Down
12 changes: 11 additions & 1 deletion src/ts/kernel/mods/server/axios.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import type { IEnvironment } from "$interfaces/modules/env";
import { __Console__ } from "$ts/console";
import { Kernel } from "$ts/env";
import { Kernel, SoundBus } from "$ts/env";
import { ArcMode } from "$ts/metadata/mode";
import { UUID } from "$ts/util/uuid";
import axios, { type AxiosRequestConfig, type InternalAxiosRequestConfig } from "axios";
Expand All @@ -13,6 +13,16 @@ export const Backend = axios.create({
},
});

Backend.interceptors.request.use((config) => {
SoundBus?.playSound("arcos.bip");
return config;
})

Backend.interceptors.response.use((config) => {
SoundBus?.playSound("arcos.bop");
return config;
})

Backend.interceptors.request.use(
(config) => {
config.headers.set("X-Request-ID", Kernel?.getModule<IEnvironment>("env").get("dispatch_sock_id"));
Expand Down
10 changes: 8 additions & 2 deletions src/ts/kernel/mods/soundbus/index.ts
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
import type { IWaveKernel } from "$interfaces/kernel";
import type { ISoundbus } from "$interfaces/modules/soundbus";
import { Env } from "$ts/env";
import { KernelModule } from "$ts/kernel/module";
import type { SoundBusStore, SoundStore } from "$types/soundbus";
import { ArcSounds } from "./store";

export class SoundBus extends KernelModule implements ISoundbus {
private store: SoundStore = {};
private _bus: SoundBusStore = {};
private readonly SOUNDBUS_LIMIT = 40;

//#region LIFECYCLE

Expand All @@ -21,9 +21,15 @@ export class SoundBus extends KernelModule implements ISoundbus {

public playSound(id: string, volume = 1) {
this.isKmod();
if (Env.get("safemode")) return;
// if (Env.get("safemode")) return;
if (!this.store[id]) return false;

const totalCount = Object.values(this._bus)
.map((s) => s.length)
.reduce((a, b) => a + b, 0);

if (totalCount > this.SOUNDBUS_LIMIT) return false;

this.Log(`Playing sound ${id} from store`);

const element = document.createElement("audio");
Expand Down
4 changes: 4 additions & 0 deletions src/ts/kernel/mods/soundbus/store.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ import click from "$assets/audio/click.wav";
import systemLogoff from "$assets/audio/logoff.wav";
import systemLogon from "$assets/audio/logon.wav";
import mwomp from "$assets/audio/mwomp.mp3";
import bip from "$assets/audio/bip.wav";
import bop from "$assets/audio/bop.wav";

export const ArcSounds: SoundStore = {
"arcos.dialog.error": dialogError,
Expand All @@ -20,4 +22,6 @@ export const ArcSounds: SoundStore = {
"arcos.click": click,
"arcos.mwomp": mwomp,
"646973636F72640A": v646973636F72640A,
"arcos.bip": bip,
"arcos.bop": bop
};
3 changes: 2 additions & 1 deletion src/ts/servicehost/services/AppStorage/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import type { IApplicationStorage } from "$interfaces/services/AppStorage";
import type { IThirdPartyAppProcess } from "$interfaces/thirdparty";
import { BuiltinAppImportPathAbsolutes } from "$ts/apps/store";
import { Daemon } from "$ts/daemon";
import { ArcOSVersion, Env, Fs, SysDispatch } from "$ts/env";
import { ArcOSVersion, Env, Fs, SoundBus, SysDispatch } from "$ts/env";
import { ArcBuild } from "$ts/metadata/build";
import { ArcMode } from "$ts/metadata/mode";
import { CommandResult } from "$ts/result";
Expand Down Expand Up @@ -63,6 +63,7 @@ export class ApplicationStorage extends BaseService implements IApplicationStora

const end = performance.now() - start;
const appCopy = await deepCopyWithBlobs<App>(app);
SoundBus?.playSound("arcos.bop");

appCopy._internalSysVer = `v${ArcOSVersion}-${ArcMode()}_${ArcBuild()}`;
appCopy._internalOriginalPath = path;
Expand Down
10 changes: 9 additions & 1 deletion src/ts/servicehost/services/GlobalDispatch/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import type { IUserDaemon } from "$interfaces/daemon";
import type { IServerManager } from "$interfaces/modules/server";
import type { IGlobalDispatch } from "$interfaces/services/GlobalDispatch";
import { Daemon } from "$ts/daemon";
import { Env, getKMod, Stack, SysDispatch } from "$ts/env";
import { Env, getKMod, SoundBus, Stack, SysDispatch } from "$ts/env";
import { Backend } from "$ts/kernel/mods/server/axios";
import type { ServiceHost } from "$ts/servicehost";
import { BaseService } from "$ts/servicehost/base";
Expand Down Expand Up @@ -40,6 +40,14 @@ export class GlobalDispatch extends BaseService implements IGlobalDispatch {
resolve();
});

this.client.onAnyOutgoing(() => {
SoundBus?.playSound("arcos.bip");
});

this.client.onAny(() => {
SoundBus?.playSound("arcos.bop");
});

this.client.on("kicked", () => {
const daemon = Stack.getProcess<IUserDaemon>(+Env.get("userdaemon_pid"));
daemon?.power?.logoff();
Expand Down