-
Notifications
You must be signed in to change notification settings - Fork 245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Encoding problem in chat example #56
Comments
Good news is I can reproduce this. Bad news is that at a glance it appears to be an error in one of the dependencies, either gevent-websocket or gevent-socketio. Now currently django-socketio is tied to very outdated versions of those, so in all likelihood, the bug may have already been fixed in those. So this issue is more or less dependant on #19 being resolved, at which point this may no longer even be a problem. I'll leave it open for now just in case. |
In case anyone is still facing this problem, my workaround on it consisted in converting the socket message to an array of char codes and stringified with JSON. When receiving the message, it is need to parse the message back to the array of code (JSON.parse), and converting it to string again. See helper functions bellow: function stringify_char_coded(json_obj) {
var stringfied = JSON.stringify(json_obj);
var char_codes = [];
for (var i=0; i < stringfied.length; i++) {
char_codes.push(stringfied.charCodeAt(i));
}
return JSON.stringify(char_codes);
}
function parse_char_coded(str) {
var char_codes = JSON.parse(str);
var s = "";
for (var i=0; i < char_codes.length; i++) {
s += String.fromCharCode(char_codes[i]);
}
return JSON.parse(s);
} |
I'm using the chat example, and I'm getting some problems in the encoding. Specifically, if I use the letter "á" in a message inside a room, the connection drops.
To reproduce the error, use the example along with
I just start using it, so I don't have so much experience to tackle the error. Nevertheless, I hope the attached log from the socket_io helps.
The text was updated successfully, but these errors were encountered: