Created
September 10, 2014 11:10
-
-
Save vird/c3d71a76067f46610984 to your computer and use it in GitHub Desktop.
primus+engine.io can't recive UTF-8
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
websocket | |
Connection Close Frame (Opcode 8) 2 14:10:04 | |
Connection Close Frame (Opcode 8, mask) 0 14:10:04 | |
4{"switch":"pong±"} 20 14:10:04 | |
4{"switch":"crash_my_connection"} 33 14:10:04 | |
4{"switch":"pongРУССÐÐÐ"} 32 14:10:02 | |
4{"switch":"Make me can't parse"} 33 14:10:02 | |
4{"switch":"pong"} 18 14:10:00 | |
4{"switch":"ping"} 18 14:10:00 | |
5 1 14:09:59 | |
3probe 6 14:09:59 | |
2probe 6 14:09:59 | |
console | |
Object {switch: "pong"} |
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
websocket | |
{"switch":"pong±"} 19 14:09:16 | |
{"switch":"crash_my_connection"} 32 14:09:16 | |
{"switch":"pongРУССÐÐÐ"} 31 14:09:14 | |
{"switch":"Make me can't parse"} 32 14:09:14 | |
{"switch":"pong"} 17 14:09:12 | |
{"switch":"ping"} 17 14:09:12 | |
console | |
Object {switch: "pong"} (index):8 | |
Object {switch: "pongРУССКИЙ"} (index):8 | |
Object {switch: "pong±"} |
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
process.on 'uncaughtException', (err) -> | |
console.log err | |
console.log err.stack | |
express = require 'express' | |
http = require 'http' | |
Primus = require 'primus' | |
body_parser = require 'body-parser' | |
compression = require 'compression' | |
# ################################################################################################### | |
app = express() | |
app.use compression() | |
app.use body_parser.urlencoded extended: true | |
app.get '/', (req, res, next)-> | |
res.end """ | |
<html> | |
<head> | |
<title>Test websocket minimal test UTF8</title> | |
<script src="/primus/primus.js"></script> | |
<script> | |
window.websocket = websocket = new Primus(location.origin) | |
websocket.on('data', function(data){ | |
console.log(data) | |
}); | |
setTimeout(function(){ | |
websocket.write({switch:"ping"}); | |
},3000); | |
setTimeout(function(){ | |
websocket.write({switch:"Make me can't parse"}); | |
},5000); | |
setTimeout(function(){ | |
websocket.write({switch:"crash_my_connection"}); | |
},7000); | |
</script> | |
</head> | |
<body></body> | |
</html> | |
"""#" | |
server = http.createServer(app).listen(1337) | |
primus = new Primus server, | |
# transformer : 'engine.io' | |
transformer : 'websockets' | |
primus.on 'connection', (socket)-> | |
socket.on 'data', (data)-> | |
switch data.switch | |
when "ping" | |
socket.write | |
'switch':'pong' | |
when "crash_my_connection" | |
socket.write | |
'switch':'pong±' | |
when "Make me can't parse" | |
socket.write | |
'switch':'pongРУССКИЙ' | |
console.log "started" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment