Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ip select #12

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
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: 4 additions & 0 deletions src/ui/src/app/globals.css
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,8 @@

.text-transparent {
color: transparent !important;
}

.bg-transparent {
background-color: transparent !important;
}
19 changes: 13 additions & 6 deletions src/ui/src/app/page.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -9,16 +9,13 @@ import bong from '../../public/bong.mp3';
// @ts-ignore
import bloop from '../../public/bloop.mp3';

const URI = "192.168.42.121";

export default function Home() {
const ws = new WebSocket(`ws://${URI}:8000/ws`);
const canvasRef = useRef<HTMLCanvasElement>(null);
const [bongSfx] = useSound(bong);
const [bloopSfx] = useSound(bloop);

const playBong = () => {
fetch(`http://${URI}:8000/sfx`, {
fetch(`http://${ip}:8000/sfx`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -31,7 +28,7 @@ export default function Home() {
};

const playBloop = () => {
fetch(`http://${URI}:8000/sfx`, {
fetch(`http://${ip}:8000/sfx`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand All @@ -49,8 +46,10 @@ export default function Home() {
const [down, setDown] = useState(0);
const [rotateleft, setRotateLeft] = useState(0);
const [rotateright, setRotateRight] = useState(0);
const [ip, setIp] = useState("localhost");

useInsertionEffect(() => {
const ws = new WebSocket(`ws://${ip}:8000/ws`);
ws.onmessage = (event) => {
if (event.data instanceof Blob) {
const reader = new FileReader();
Expand Down Expand Up @@ -148,7 +147,7 @@ export default function Home() {
}, [])

useEffect(() => {
fetch(`http://${URI}:8000/command`, {
fetch(`http://${ip}:8000/command`, {
method: 'POST',
headers: {
'Content-Type': 'application/json',
Expand Down Expand Up @@ -208,6 +207,14 @@ export default function Home() {
</div>
</a>
<div className="flex flex-col items-center justify-center h-full">
<div className="fixed top-4 right-4">
<select className="h-6 bg-transparent text-blue font-bold text-lg text-right" onChange={e => {
setIp(e.target.value);
}}>
<option value="localhost">localhost</option>
<option value="192.168.42.121">192.168.42.121</option>
</select>
</div>
<div className="mb-10 space-x-10">
<button className=" hover:text-white text-3xl text-blue font-bold active:border-none" onClick={playBloop}>
BING
Expand Down