comparison mod_websocket/mod_websocket.lua @ 691:04662cc35280

mod_websocket: Answer ping frames
author Florian Zeitz <florob@babelmonkeys.de>
date Sun, 27 May 2012 19:30:37 +0200
parents 5acc203972f3
children 2de21fa40382
comparison
equal deleted inserted replaced
690:5acc203972f3 691:04662cc35280
260 local buffer = ""; 260 local buffer = "";
261 function session.data(data) 261 function session.data(data)
262 local frame = parse_frame(data); 262 local frame = parse_frame(data);
263 263
264 module:log("debug", "Websocket received: %s (%i bytes)", frame.data, #frame.data); 264 module:log("debug", "Websocket received: %s (%i bytes)", frame.data, #frame.data);
265 if frame.opcode == 0x00 or frame.opcode == 0x01 then -- Text or continuation frame 265 if frame.opcode == 0x0 or frame.opcode == 0x1 then -- Text or continuation frame
266 buffer = buffer .. frame.data; 266 buffer = buffer .. frame.data;
267 elseif frame.opcode == 0x9 then -- Ping frame
268 frame.opcode = 0xA;
269 conn:write(build_frame(frame));
270 return;
267 else 271 else
268 log("warn", "Received frame with unsupported opcode %i", frame.opcode); 272 log("warn", "Received frame with unsupported opcode %i", frame.opcode);
269 return; 273 return;
270 end 274 end
271 275