Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Use LZMA compression for PPU:Initialize message.

Websocket connection is being dropped when deployed on Nodejitsu,
presumably due to the large size of the PPU:Initialize packet.
  • Loading branch information...
commit 6a772f83204f415a34f251ff6890abdbdfccaa4a 1 parent 1d1adf6
@ecin ecin authored
View
19 package.json
@@ -1,11 +1,18 @@
{
- "name":"joynes",
- "version":"0.0.1a",
- "main":"main",
- "dependencies":
- {
+ "name": "joynes",
+ "version": "0.0.1a",
+ "main": "main",
+ "dependencies": {
"express": "~2.5",
"ejs": "~0.6",
- "socket.io": "~0.8"
+ "socket.io": "~0.8",
+ "lzma": "~1.2"
+ },
+ "subdomain": "joynes",
+ "scripts": {
+ "start": "server.js"
+ },
+ "engines": {
+ "node": "0.6.x"
}
}
View
2  public/js/joynes/base.js
@@ -20,6 +20,8 @@ joynes.Base.prototype = {
readStatusRegister: 17,
},
+ compressor : LZMA,
+
partner : function(command, data) {
var self = this;
self.socket.emit("proxy", {"command": command, "data": data })
View
6 public/js/joynes/master.js
@@ -98,7 +98,7 @@ joynes.Master.prototype = {
this.nes.ppu.ptTile[1].initialized = true;
console.log(this.nes.ppu.ptTile[1]);
var self = this;
- self.partner("PPU:Initialize", {
+ var payload = {
"instruction": self.instruction_id,
"vramMem": this.nes.ppu.vramMem,
"spriteMem": this.nes.ppu.spriteMem,
@@ -171,7 +171,9 @@ joynes.Master.prototype = {
"palTable": this.nes.ppu.palTable,
"controlReg1Value": this.nes.ppu.controlReg1Value,
"controlReg2Value": this.nes.ppu.controlReg2Value,
- });
+ }
+
+ self.partner("PPU:Initialize", self.compressor.compress(JSON.stringify(payload)));
self.partner("MMAP:Initialize", {
"mapperType": self.nes.rom.mapperType,
View
1  public/js/joynes/slave.js
@@ -22,6 +22,7 @@ joynes.Slave.prototype = {
});
self.socket.on("PPU:Initialize", function(data) {
+ data = JSON.parse(self.compressor.decompress(data));
self.nes.ppu.vramMem = data["vramMem"];
self.nes.ppu.spriteMem = data["spriteMem"];
self.nes.ppu.vramAddress = data["vramAddress"];
View
3,826 public/js/lzma_worker.js
3,826 additions, 0 deletions not shown
View
7 views/index.ejs
@@ -43,15 +43,16 @@
buttons: {
wrapper:'<span class="message-box-confirm"></span>',
separator:' '
- }
+ }
});
- socket = io.connect('http://' + document.location.hostname + ':3333/');
+ socket = io.connect('http://' + document.location.hostname + ':' + (document.location.port || '80') + '/');
// Display shareId
socket.on("connect", function(evt) {
var shareId = encodeShareId(socket.socket.sessionid);
var hostname = location.protocol + "//" + location.host + "/";
+ console.log(hostname + shareId);
document.querySelector("#shareId span").innerHTML += hostname + shareId;
});
@@ -170,7 +171,7 @@
displayPoster(title);
}
-
+
game.onclick = function(event) {
var title = event.target.getAttribute("data-game");
if (partnerIdPresent) {
View
1  views/layout.ejs
@@ -3,6 +3,7 @@
<head>
<title>Copypastel presents: Joynes</title>
<link rel="stylesheet" href="/css/style.css" type="text/css" />
+ <script type="text/javascript" src="/js/lzma_worker.js"></script>
<script type="text/javascript" src="/js/jquery-1.4.2.min.js"></script>
<script type="text/javascript" src="/js/jquery.confirm.js"></script>
<script type="text/javascript" src="/socket.io/socket.io.js"></script>
Please sign in to comment.
Something went wrong with that request. Please try again.