BananaBread icon indicating copy to clipboard operation
BananaBread copied to clipboard

Webrtc merge

Open modeswitch opened this issue 11 years ago • 9 comments

Webrtc multiplayer support for BananaBread; Updated art assets and new levels from gk; Updated Makefile to avoid rebuilding packages all the time; Added manifest.txt and publish.sh to make packaging for upload to demo site easier

modeswitch avatar Aug 29 '13 15:08 modeswitch

Great, thanks. Comments:

  1. Please add // XXX EMSCRIPTEN comments where you modified the engine cpp files
  2. We need the benchmarking stuff to work (benchmark.html). It fails on [12:44:17.278] TypeError: levelTitleContainer is null @ file:///home/alon/Dev/BananaBread/cube2/js/game-setup.js.
  3. We also need the shell benchmarking to work, js js/game-setup.js in the cube2 dir. I tried to fix that and got further with
diff --git a/cube2/js/game-setup.js b/cube2/js/game-setup.js
index 6d74f1a..de9a56c 100644
--- a/cube2/js/game-setup.js
+++ b/cube2/js/game-setup.js
@@ -1,9 +1,18 @@
 // Setup compiled code parameters and interaction with the web page

+var shell = typeof window == 'undefined';
+
+if (shell) {
+  load('game/headless.js');
+  load('game/headlessCanvas.js');
+  console = { info: print, log: print };
+  navigator = { userAgent: 'shell', platform: 'shell' };
+}
+
 var Query = {
   parse: function parse(queryString) {
     var result = {};
     var parts = queryString.split('&');
     parts.forEach(function(part) {
       var key = part.split('=')[0];
       if(!result.hasOwnProperty(key))
@@ -69,21 +78,14 @@ else
 var params = Query.parse(window.location.search.substring(1));
 console.info('params', params);

 var url = window.location.toString();
 url = clearQuery(url, 'serve');
 url = clearQuery(url, 'windowed');

-var shell = typeof window == 'undefined';
-
-if (shell) {
-  load('game/headless.js');
-  load('game/headlessCanvas.js');
-}
-
 function checkPageParam(param) {
   console.log('checkPageParam:', param);
   return Query.defined(params, param);
 }

 Date.realNow = Date.now;
 if (checkPageParam('deterministic')) {

but then it hangs. I wonder if we don't just want to disable networking or something like that.

kripken avatar Aug 29 '13 19:08 kripken

Sorry to bump this, but why wasn't it merged?

klaussilveira avatar Mar 24 '15 14:03 klaussilveira

What was the hold up on this? Any chance @kripken or @modeswitch could fix the conflicts so it can be merged?

slacka avatar Jan 12 '17 23:01 slacka

I don't remember the history here, but webrtc support in emscripten itself has stagnated, the tests have been disabled. We need more help in that area.

kripken avatar Jan 13 '17 00:01 kripken

I believe we should switch to a more robust library like socket.io or engine.io with NodeJS for server side, like Inexor has done.

noahcoetsee avatar May 17 '18 00:05 noahcoetsee

@modeswitch @kripken I know this is necroposting, but I was curious about BananaBread as an example of networking on Emscripten.

Are there more modern approaches? Or is this PR still a good piece of code to read and learn from?

VinnyVicious avatar Nov 04 '22 15:11 VinnyVicious

这里是龙嫣然的邮箱,感谢您的来信。

roxanne-longyanran avatar Nov 04 '22 15:11 roxanne-longyanran

@VinnyVicious I actually am not sure what the best example of that is atm. Might want to open a discussion on the emscripten repo perhaps.

kripken avatar Nov 04 '22 16:11 kripken

@VinnyVicious This was intended to be a proof-of-concept. The underlying concepts should still work, even though the code is outdated. I won't guarantee that there isn't a more modern approach.

modeswitch avatar Nov 09 '22 22:11 modeswitch