Skip to content

Commit

Permalink
Merge pull request #392 from Mindgamesnl/feature/voice-channels
Browse files Browse the repository at this point in the history
Feature/voice-channels
  • Loading branch information
Mindgamesnl authored Feb 4, 2024
2 parents 725d0a4 + 460e9e4 commit 6199b7a
Show file tree
Hide file tree
Showing 63 changed files with 1,195 additions and 402 deletions.
41 changes: 41 additions & 0 deletions client/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions client/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
"react-router": "^6.4.5",
"react-router-dom": "^6.4.5",
"react-toastify": "9.1.3",
"react-tooltip": "^5.26.0",
"redux": "^4.2.0",
"socket.io-client": "^2.5.0",
"web-vitals": "^2.1.4",
Expand Down
3 changes: 3 additions & 0 deletions client/public/en.lang
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,9 @@ vc.peersHiddenText=This server has disabled the ability to see who is in voice c
vc.isTalking=is talking
vc.people=people
vc.deafened=You are currently deafened
vc.tooltip.local=Proximity Voice Chat
vc.tooltip.global=Global Voice Chat


settings.voicechat.echocancel.title=Echo cancellation
settings.voicechat.echocancel.body=This will attempt to cancel out any echo that your microphone picks up, this is useful if you're using speakers instead of headphones but may make your harder to hear on some platforms.
Expand Down
2 changes: 1 addition & 1 deletion client/public/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"buildMajor":1,"buildMinor":125,"buildRevision":197,"buildTag":"dev","buildDate":"Fri Jan 26 2024","build":"1.125.197 dev"}
{"buildMajor":1,"buildMinor":125,"buildRevision":201,"buildTag":"dev","buildDate":"Sun Feb 04 2024","build":"1.125.201 dev"}
1 change: 1 addition & 0 deletions client/src/App.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import './App.css';
import 'react-tooltip/dist/react-tooltip.css';
import React from 'react';
import { Provider } from 'react-redux';
import OpenAudioAppContainer from './client/OpenAudioAppContainer';
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ export function HandleVoiceSubscription(data) {
} = peers[i];

let options = null;
if (data.options) {
options = peerOptionsFromObj(data.options);
if (peers[i].options) {
options = peerOptionsFromObj(peers[i].options);
} else {
options = new VoicePeerOptions();
}
Expand Down
19 changes: 18 additions & 1 deletion client/src/client/services/voice/VoiceModule.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { MicrophoneProcessor } from './processing/MicrophoneProcessor';
import { SocketManager } from '../socket/SocketModule';
import * as PluginChannel from '../../util/PluginChannel';
import { VoicePeer } from './peers/VoicePeer';
import { feedDebugValue } from '../debugging/DebugService';
import { debugLog, feedDebugValue } from '../debugging/DebugService';
import { DebugStatistic } from '../debugging/DebugStatistic';
import { setTab } from '../../../components/tabwindow/TabWindow';
import { StringifyError } from '../../util/errorreformat';
Expand Down Expand Up @@ -207,6 +207,23 @@ export const VoiceModule = new class IVoiceModule {
}

removePeer(playerStreamKey) {
// FALLBACK! IF WE GET A UUID WE NEED TO RECOVER AND FIND THE PEER'S STREAM KEY
if (playerStreamKey.length > 32) {
debugLog('FALLBACK: UUID DETECTED, TRYING TO RECOVER STREAM KEY');
let foundKey = null;
this.peerMap.forEach((peer, key) => {
if (peer.peerUuid === playerStreamKey) {
foundKey = key;
}
});
if (foundKey) {
playerStreamKey = foundKey;
} else {
debugLog('FALLBACK: COULD NOT RECOVER STREAM KEY, ABORTING');
return;
}
}

const peer = this.peerMap.get(playerStreamKey);
if (peer) {
peer.stop();
Expand Down
6 changes: 4 additions & 2 deletions client/src/client/services/voice/peers/VoicePeerOptions.jsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { getGlobalState } from '../../../../state/store';
import { debugLog } from '../../debugging/DebugService';

export class VoicePeerOptions {
constructor(
Expand All @@ -11,8 +12,9 @@ export class VoicePeerOptions {
}

export function peerOptionsFromObj(obj) {
debugLog('peerOptionsFromObj', obj);
return new VoicePeerOptions(
obj.visible ?? true,
obj.spatialAudio ?? getGlobalState().settings.voicechatSurroundSound,
(obj.visible !== undefined) ? obj.visible : true,
(obj.spatialAudio !== undefined) ? obj.spatialAudio : getGlobalState().settings.voicechatSurroundSound,
);
}
Original file line number Diff line number Diff line change
@@ -1,9 +1,18 @@
import React from 'react';
import { msg } from '../../client/OpenAudioAppContainer';

export function GlobeSVG() {
export function GlobalSvg() {
// remix of https://www.svgrepo.com/svg/299039/group-team?edit=true
// by: SVG Repo
return (
// source: https://www.svgrepo.com/svg/507325/globe-alt
<svg xmlns="http://www.w3.org/2000/svg" className="inline !mr-1" viewBox="0 0 24 24" fill="none">
<svg
xmlns="http://www.w3.org/2000/svg"
data-tooltip-id="global-voice-tooltip"
data-tooltip-content={msg('vc.tooltip.global')}
className="inline !mr-1"
viewBox="0 0 24 24"
fill="none"
>
<path
d="M11 20.8464C11 21.4378 10.4874 21.9041 9.909 21.781C5.70686 20.8871 2.48103 17.3537 2.04924 12.9986C1.99475 12.449 2.44772 12 3 12H6C6.55228 12 7 12.4477 7 13C7 14.6569 8.34315 16 10 16C10.5523 16 11 16.4477 11 17V20.8464Z"
fill="#948b7f"
Expand Down
69 changes: 0 additions & 69 deletions client/src/components/icons/peerprox.jsx

This file was deleted.

41 changes: 41 additions & 0 deletions client/src/components/icons/proxsvg.jsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
import React from 'react';
import { msg } from '../../client/OpenAudioAppContainer';

export function ProximitySvg() {
// source: https://www.svgrepo.com/svg/526380/translation-2
return (
<svg
className="inline !mr-1"
viewBox="0 0 24 24"
xmlns="http://www.w3.org/2000/svg"
data-tooltip-id="global-voice-tooltip"
data-tooltip-content={msg('vc.tooltip.local')}
>
<g id="SVGRepo_bgCarrier" strokeWidth="0" />
<g id="SVGRepo_tracerCarrier" strokeLinecap="round" strokeLinejoin="round" />
<g id="SVGRepo_iconCarrier">
<path
fillRule="evenodd"
clipRule="evenodd"
d="M12 8.03471C9.3028 8.03471 7.11628 10.1864 7.11628 12.8406C7.11628 14.1679 7.66214 15.3684 8.54669 16.2388C8.81915 16.5069 8.81915 16.9417 8.54669 17.2098C8.27423 17.4779 7.83249 17.4779 7.56003 17.2098C6.4245 16.0923 5.72093 14.5467 5.72093 12.8406C5.72093 9.42803 8.53217 6.66161 12 6.66161C15.4678 6.66161 18.2791 9.42803 18.2791 12.8406C18.2791 14.5467 17.5755 16.0923 16.44 17.2098C16.1675 17.4779 15.7258 17.4779 15.4533 17.2098C15.1809 16.9417 15.1809 16.5069 15.4533 16.2388C16.3379 15.3684 16.8837 14.1679 16.8837 12.8406C16.8837 10.1864 14.6972 8.03471 12 8.03471Z"
fill="#657ec7"
/>
<path
fillRule="evenodd"
clipRule="evenodd"
d="M12 4.3731C7.24778 4.3731 3.39535 8.16412 3.39535 12.8406C3.39535 15.179 4.35769 17.2949 5.91559 18.828C6.18805 19.0961 6.18805 19.5308 5.91559 19.7989C5.64313 20.067 5.20139 20.067 4.92893 19.7989C3.12005 18.0189 2 15.5578 2 12.8406C2 7.40578 6.47715 3 12 3C17.5228 3 22 7.40578 22 12.8406C22 15.5578 20.8799 18.0189 19.0711 19.7989C18.7986 20.067 18.3569 20.067 18.0844 19.7989C17.8119 19.5308 17.8119 19.0961 18.0844 18.828C19.6423 17.2949 20.6047 15.179 20.6047 12.8406C20.6047 8.16412 16.7522 4.3731 12 4.3731Z"
fill="#657ec7"
/>
<path
d="M10.3099 17.3441C11.0774 16.4683 11.4612 16.0304 11.935 16.002C11.9783 15.9993 12.0217 15.9993 12.065 16.002C12.5389 16.0304 12.9226 16.4683 13.6901 17.3441C15.3601 19.2497 16.1951 20.2025 15.9613 21.0245C15.9412 21.0952 15.9163 21.1639 15.8867 21.2301C15.5426 22 14.3617 22 12 22C9.63827 22 8.45741 22 8.11329 21.2301C8.08371 21.1639 8.05875 21.0952 8.03866 21.0245C7.80489 20.2025 8.63989 19.2497 10.3099 17.3441Z"
fill="#FEDD58"
/>
<path
d="M14.5 12.5C14.5 13.8807 13.3807 15 12 15C10.6193 15 9.5 13.8807 9.5 12.5C9.5 11.1193 10.6193 10 12 10C13.3807 10 14.5 11.1193 14.5 12.5Z"
fill="#FEDD58"
/>
</g>
</svg>

);
}
3 changes: 3 additions & 0 deletions client/src/components/voice/VoicePeerBox.jsx
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import React from 'react';
import { connect } from 'react-redux';
import { Tooltip } from 'react-tooltip';
import { VoicePeerRow } from './VoicePeerRow';
import { msg } from '../../client/OpenAudioAppContainer';

Expand Down Expand Up @@ -115,6 +116,8 @@ function VoicePeerBox(props) {
</div>
</div>
</div>
<Tooltip id="proximity-voice-tooltip" />
<Tooltip id="global-voice-tooltip" />
</div>
);
}
Expand Down
6 changes: 3 additions & 3 deletions client/src/components/voice/VoicePeerRow.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,9 @@ import './voicecard.css';
import Cookies from 'js-cookie';
import { VoiceModule } from '../../client/services/voice/VoiceModule';
import { getVolumeForPeer } from '../../client/services/voice/peers/VoicePeer';
import { GlobeSVG } from '../icons/global';
import { PeerMutedSvg } from '../icons/peermuted';
import { PeerProximitySvg } from '../icons/peerprox';
import { ProximitySvg } from '../icons/proxsvg';
import { GlobalSvg } from '../icons/globalsvg';

export class VoicePeerRow extends React.Component {
static propTypes = {
Expand Down Expand Up @@ -131,7 +131,7 @@ export class VoicePeerRow extends React.Component {
<div className="flex items-centerhidden-on-mobile py-1">
<h1 className="ml-2">
{muted ? (<PeerMutedSvg />) : null}
{this.props.spatialAudio ? (<GlobeSVG />) : <PeerProximitySvg />}
{this.props.spatialAudio ? (<ProximitySvg />) : <GlobalSvg />}
{name}
{showVolume ? (
<small className="soft-text">
Expand Down
2 changes: 1 addition & 1 deletion client/src/metadata.json
Original file line number Diff line number Diff line change
@@ -1 +1 @@
{"buildMajor":1,"buildMinor":125,"buildRevision":197,"buildTag":"dev","buildDate":"Fri Jan 26 2024","build":"1.125.197 dev"}
{"buildMajor":1,"buildMinor":125,"buildRevision":201,"buildTag":"dev","buildDate":"Sun Feb 04 2024","build":"1.125.201 dev"}
2 changes: 1 addition & 1 deletion dev-resources/spawn-test-spigot.sh
Original file line number Diff line number Diff line change
Expand Up @@ -29,4 +29,4 @@ echo "Starting server.."
rm world/session.lock
rm world_the_end/session.lock
rm world_nether/session.lock
java -Xms3G -Xmx3G -jar spigot-1.20.2.jar nogui
java -Xms3G -Xmx3G -DIReallyKnowWhatIAmDoingISwear -jar spigot-1.20.2.jar nogui
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import com.craftmend.openaudiomc.api.enums.ModuleEvent;
import com.craftmend.openaudiomc.api.interfaces.ExternalModule;
import com.craftmend.openaudiomc.generic.commands.CommandService;
import com.craftmend.openaudiomc.generic.commands.enums.CommandContext;
import com.craftmend.openaudiomc.generic.environment.MagicValue;
import com.craftmend.openaudiomc.generic.proxy.interfaces.UserHooks;
import com.craftmend.openaudiomc.generic.state.StateService;
Expand All @@ -27,8 +28,10 @@

public final class Vistas extends ExternalModule implements Listener {

@Getter private static Vistas instance;
@Getter private UUID serverId = UUID.randomUUID();
@Getter
private static Vistas instance;
@Getter
private UUID serverId = UUID.randomUUID();

public Vistas() {
instance = this;
Expand Down Expand Up @@ -59,8 +62,11 @@ public void on(ModuleEvent event) {
OpenAudioMc.getService(ProxyModule.class).refresh();
if (event == ModuleEvent.PLATFORM_LOADED) {
// finished startup
OpenAudioMc.getService(CommandService.class).registerSubCommand(new VistasEvalCommand());
OpenAudioMc.getService(CommandService.class).registerSubCommand(new VistasLinkCommand());
OpenAudioMc.getService(CommandService.class).registerSubCommands(
CommandContext.OPENAUDIOMC,
new VistasEvalCommand(),
new VistasLinkCommand()
);
}

if (event == ModuleEvent.MODULES_LOADED) {
Expand Down
Loading

0 comments on commit 6199b7a

Please sign in to comment.