-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
209 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,3 @@ | ||
/target | ||
/dist | ||
/dist | ||
.stage |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,8 +1,8 @@ | ||
<script integrity=sha384-DXfxbHnmRjXl3uhZSP4S1IWEe3DfX/sHDa2A7iHxmUB6Ag+87PaP8wV2AtDOwHfm src=./restart-audio-context-8127143435824044.js type=module></script><link href=./index-56627a79e0752a1c.css integrity=sha384-m/ivHNojsD/VAvwMMce+fhrN8VxOZuZt5hms1JExuO36KLCDKKRGDtjLXSlnQq0B rel=stylesheet><script nonce="CuZ6N6gVlCtFaHRLASTYew==" type=module>import init, * as bindings from './my_bevy_game-ba276c861f566071.js'; | ||
const wasm = await init('./my_bevy_game-ba276c861f566071_bg.wasm'); | ||
<script integrity=sha384-DXfxbHnmRjXl3uhZSP4S1IWEe3DfX/sHDa2A7iHxmUB6Ag+87PaP8wV2AtDOwHfm src=./restart-audio-context-8127143435824044.js type=module></script><link href=./index-56627a79e0752a1c.css integrity=sha384-m/ivHNojsD/VAvwMMce+fhrN8VxOZuZt5hms1JExuO36KLCDKKRGDtjLXSlnQq0B rel=stylesheet><script nonce="iGEe4s3oX1SQSqG3f7F0nQ==" type=module>import init, * as bindings from './my_bevy_game-a8b691d97a29bb5e.js'; | ||
const wasm = await init('./my_bevy_game-a8b691d97a29bb5e_bg.wasm'); | ||
|
||
|
||
window.wasmBindings = bindings; | ||
|
||
|
||
dispatchEvent(new CustomEvent("TrunkApplicationStarted", {detail: {wasm}}));</script><title></title><link crossorigin href=./my_bevy_game-ba276c861f566071.js integrity=sha384-V4s1vj0yqE1RFPdVDehr2zhrSjFVg8hUJ+/dMr5hrAOQeCZF2g5g7JpZIG1d5ckp rel=modulepreload><link as=fetch crossorigin href=./my_bevy_game-ba276c861f566071_bg.wasm integrity=sha384-nquPGE8gC/WOGOLHBODKfj+MdmYdAN3BHUDHFPMUcd50rWPXVOyiluRjJ6lU+nBJ rel=preload type=application/wasm></head><body></body></html> | ||
dispatchEvent(new CustomEvent("TrunkApplicationStarted", {detail: {wasm}}));</script><title>Magna Magia 0.1</title><link crossorigin href=./my_bevy_game-a8b691d97a29bb5e.js integrity=sha384-c7UPANyLeFBIKQkwGc9pZehIG28gfpnf9kE/Vdr683uKhr02PXwqPFYoO3SF24xp rel=modulepreload><link as=fetch crossorigin href=./my_bevy_game-a8b691d97a29bb5e_bg.wasm integrity=sha384-j0pisGGUlc2Jc0DvW9XqVuF2CKm1ecxJ3nEL5wBOPpjKkdbeoviN3QE5FQurmU2i rel=preload type=application/wasm></head><body></body></html> |
Large diffs are not rendered by default.
Oops, something went wrong.
Binary file renamed
BIN
+10.5 MB
docs/my_bevy_game-ba276c861f566071_bg.wasm → docs/my_bevy_game-a8b691d97a29bb5e_bg.wasm
Binary file not shown.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
const WebSocket = require('ws'); | ||
const port = process.env.PORT || 3000; | ||
const server = new WebSocket.Server({ port }); | ||
console.log(`Server started on port ${port}`); | ||
|
||
// https://www.npmjs.com/package/ws | ||
server.on('connection', (ws, req) => { | ||
|
||
const ip = req.socket.remoteAddress; | ||
|
||
console.log('Client connected, ip address:', ip); | ||
|
||
ws.on('error', (e) => { | ||
console.error(e); | ||
}); | ||
|
||
ws.on('message', (message, isBinary) => { | ||
console.log('received: %s', message); | ||
|
||
const data = message.toString().toUpperCase(); | ||
// ws.send(`Hello, you sent -> ${message.toString().toUpperCase()}`); | ||
|
||
server.clients.forEach(function each(client) { | ||
if (client.readyState === WebSocket.OPEN) { | ||
client.send(data, { binary: isBinary }); | ||
} | ||
}); | ||
}); | ||
}); |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
{ | ||
"name": "whiteboard", | ||
"version": "1.0.0", | ||
"description": "A simple collaborative whiteboard using socket.io", | ||
"main": "index.js", | ||
"keywords": [], | ||
"dependencies": { | ||
"ws": "^8.18.0" | ||
}, | ||
"scripts": { | ||
"start": "node index", | ||
"deploy": "gcloud run deploy magia-server --project=magia --source ." | ||
}, | ||
"author": "Damien Arrachequesne", | ||
"license": "MIT" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
<!doctype html> | ||
<html lang="en"> | ||
<head> | ||
<meta charset="UTF-8"> | ||
<title>Socket.IO</title> | ||
</head> | ||
<body> | ||
<script src="https://cdn.socket.io/4.7.5/socket.io.min.js" integrity="sha384-2huaZvOR9iDzHqslqwpR87isEmrfxqyWOF7hr7BY6KG0+hVKLoEXMPUJw3ynWuhO" crossorigin="anonymous"></script> | ||
<script src="./main.js"></script> | ||
</body> | ||
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
'use strict'; | ||
|
||
(function() { | ||
const socket = new WebSocket("ws://localhost:3000"); | ||
|
||
socket.onopen = () => { | ||
console.log('Connected to server'); | ||
|
||
socket.send('Hello from client'); | ||
}; | ||
|
||
socket.onmessage = (event) => { | ||
console.log('Message from server', event.data); | ||
|
||
socket.send(event.data.toUppserCase()); | ||
}; | ||
})(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
https://github.com/socketio/socket.io/tree/master/examples/whiteboard | ||
|
||
# Socket.IO Collaborative Whiteboard | ||
|
||
A simple collaborative whiteboard for Socket.IO | ||
|
||
## How to use | ||
|
||
``` | ||
$ npm ci && npm start | ||
``` | ||
|
||
And point your browser to `http://localhost:3000`. Optionally, specify | ||
a port by supplying the `PORT` env variable. | ||
|
||
## Features | ||
|
||
- draw on the whiteboard and all other users will see you drawings live |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,4 +20,5 @@ mod set; | |
mod states; | ||
mod tile; | ||
mod wall; | ||
mod websocket; | ||
mod world; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
#![cfg(target_arch = "wasm32")] | ||
|
||
use wasm_bindgen::prelude::*; | ||
use wasm_bindgen::{prelude::Closure, JsValue}; | ||
use web_sys::{console, ErrorEvent, MessageEvent, WebSocket}; | ||
|
||
// https://rustwasm.github.io/wasm-bindgen/examples/websockets.html | ||
pub fn send_to_server() -> Result<(), JsValue> { | ||
let url = "http://127.0.0.1:3000"; | ||
|
||
console::log_2(&JsValue::from_str("connecting "), &JsValue::from_str(url)); | ||
|
||
let ws = WebSocket::new(url)?; | ||
let cloned_ws = ws.clone(); | ||
|
||
console::log_1(&JsValue::from_str("socket created ")); | ||
|
||
let onmessage_callback = Closure::wrap(Box::new(move |e: MessageEvent| { | ||
console::log_2(&JsValue::from_str("message event"), &e.data()); | ||
}) as Box<dyn FnMut(MessageEvent)>); | ||
ws.set_onmessage(Some(onmessage_callback.as_ref().unchecked_ref())); | ||
onmessage_callback.forget(); | ||
|
||
let onerror_callback = Closure::wrap(Box::new(move |e: ErrorEvent| { | ||
console::log_2( | ||
&JsValue::from_str("error event"), | ||
&JsValue::from_str(e.message().as_str()), | ||
); | ||
}) as Box<dyn FnMut(ErrorEvent)>); | ||
ws.set_onerror(Some(onerror_callback.as_ref().unchecked_ref())); | ||
onerror_callback.forget(); | ||
|
||
let onopen_callback = Closure::wrap(Box::new(move |_| { | ||
console::log_1(&JsValue::from_str("socket opended")); | ||
|
||
cloned_ws.send_with_str("hello from rust"); | ||
}) as Box<dyn FnMut(JsValue)>); | ||
ws.set_onopen(Some(onopen_callback.as_ref().unchecked_ref())); | ||
onopen_callback.forget(); | ||
|
||
console::log_1(&JsValue::from_str("callback initialized ")); | ||
|
||
Ok(()) | ||
} |