-
Notifications
You must be signed in to change notification settings - Fork 735
get_double() asserting on valid input #22
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
Comments
Can you paste some piece of code? |
On the node server side I am sending in maoSocket.emit 'play', {file: "#{__dirname}/8sec.mp3", offset: 5.0} Then on the receiving end h.socket()->on("play", socket::event_listener([&](event& event){
message::ptr const& m = event.get_message();
map<string, message::ptr> eventObject;
String filename;
double offset = -1;
if (m->get_map().find("file") != m->get_map().end())
filename = m->get_map()["file"]->get_string();
if (m->get_map().find("offset") != m->get_map().end())
offset = m->get_map()["offset"]->get_double(); // <- Asserts here unless I use get_int()
if (m->get_map().find("event") != m->get_map().end())
eventObject = m->get_map()["event"]->get_map();
playFile(filename, eventObject, offset);
})); Thanks! |
Can you look at the actual transmitting json,I think it converted 5.0 to 5. So offset was interpreted as integer by client. |
You have had a common case. I'll think about providing generic accessors for number types. |
Thanks, I'm pretty sure the conversion from 5.0 to 5 is the culprit. But since all javascript numbers are doubles wouldn't it make sense to make get_double() always be valid on numerical values? Otherwise, we'd have to add a fractional like 0.00001 to any n.0 value before sending it in and then subtract it out on the client side. Thanks again. |
@oh3netid Yes, your're right. |
try tag 1.5.0 |
Works great! Thank you. |
Hello, I am seeing get_double() asserting on sio_message.h: 48 when I send in an object with either an integer or value like "5.0".
I guess while I'm at it I'll also request that something be done to prevent the assert on get_int() when a double is provided, like rounding or truncation?
The text was updated successfully, but these errors were encountered: