comparison rlgwebd.js @ 162:5a7e7ec136c8

Properly print session tags in the log. They are Strings and should not be formatted with %d.
author John "Elwin" Edwards
date Sat, 03 Jan 2015 20:07:42 -0500
parents ed837da65e5f
children 0f6da35b27a0
comparison
equal deleted inserted replaced
161:a2a25b7631f1 162:5a7e7ec136c8
159 while (this.framebuf.length < chunk.length + this.frameoff) { 159 while (this.framebuf.length < chunk.length + this.frameoff) {
160 var nbuf = new Buffer(this.framebuf.length * 2); 160 var nbuf = new Buffer(this.framebuf.length * 2);
161 this.framebuf.copy(nbuf, 0, 0, this.frameoff); 161 this.framebuf.copy(nbuf, 0, 0, this.frameoff);
162 this.framebuf = nbuf; 162 this.framebuf = nbuf;
163 if (this.framebuf.length > 65536) { 163 if (this.framebuf.length > 65536) {
164 tslog("Warning: Game %d frame buffer at %d bytes", this.tag(), 164 tslog("Warning: Game %s frame buffer at %d bytes", this.tag(),
165 this.framebuf.length); 165 this.framebuf.length);
166 } 166 }
167 } 167 }
168 chunk.copy(this.framebuf, this.frameoff); 168 chunk.copy(this.framebuf, this.frameoff);
169 this.frameoff += chunk.length; 169 this.frameoff += chunk.length;
205 session.on('exit', exitH); 205 session.on('exit', exitH);
206 conn.on('close', function(code, desc) { 206 conn.on('close', function(code, desc) {
207 session.removeListener('data', dataH); 207 session.removeListener('data', dataH);
208 session.removeListener('exit', exitH); 208 session.removeListener('exit', exitH);
209 if (session.tag() in sessions) 209 if (session.tag() in sessions)
210 tslog("A WebSocket watcher has left game %d", session.tag()); 210 tslog("A WebSocket watcher has left game %s", session.tag());
211 }); 211 });
212 conn.sendUTF(JSON.stringify({ 212 conn.sendUTF(JSON.stringify({
213 "t": "w", "w": session.w, "h": session.h, 213 "t": "w", "w": session.w, "h": session.h,
214 "p": session.pname, "g": session.game.uname 214 "p": session.pname, "g": session.game.uname
215 })); 215 }));
934 return; 934 return;
935 } 935 }
936 var tsession = sessions[watchmatch[1]]; 936 var tsession = sessions[watchmatch[1]];
937 var conn = wsRequest.accept(null, wsRequest.origin); 937 var conn = wsRequest.accept(null, wsRequest.origin);
938 new wsWatcher(conn, tsession); 938 new wsWatcher(conn, tsession);
939 tslog("Game %d is being watched via WebSockets", tsession.tag()); 939 tslog("Game %s is being watched via WebSockets", tsession.tag());
940 } 940 }
941 else if (playmatch !== null) { 941 else if (playmatch !== null) {
942 wsStart(wsRequest); 942 wsStart(wsRequest);
943 } 943 }
944 else if (wsRequest.resourceURL.pathname == "/status") { 944 else if (wsRequest.resourceURL.pathname == "/status") {