binary in message::list results in error
Hey,
I want to emit an event which holds one binary object and a few strings. I thought the message::list approach as seen in your Readme would work.
I tried:
message::list argumentList("test1");
argumentList.push(ofToString(sendcount));
argumentList.push(std::make_shared<std::string>(buff, buffer.size()));
h.socket()->emit("annotation_with_image", argumentList);
But I get following error:
error: no viable conversion from 'shared_ptr<std::__1::basic_string<char>>' to 'const shared_ptr<sio::message>'
argumentList.push(buf);
It seem the list doesn't accept the datatype returned by make_shared. What would I need to change to send binary data (an image) along with some strings in a single event?
Reversing the function calls works without flaws interestingly:
message::list argumentList(std::make_shared<std::string>(buff, buffer.size()));
argumentList.push(string_message::create("foo2"));
argumentList.push(string_message::create("foo3"));
I'd close this, but an explanation why my first attempt doesnt work, would be good. Furthermore it should optimally be versatile enough to allow my first attempt. :)
I think it would have worked if you'd have done
message::list argumentList("test1"); argumentList.push(binary_message::create(std::make_sharedstd::string(buff, buffer.size())));
It only due to the fact that there are a lot of constructor defined but only one "push" method taking message::ptr as argument. We could effectively overload this method to have all the combinations available for constructors.
@macq-vraman ah, there is binary_message::create? Interesting! Didn't see it mentioned and didn't look thoroughly enough in the code, apparently. will try tommorow, thanks!
update (4. september):
@macq-vraman it works :+1: I am leaving this issue to the devs to close or keep open.
Was this issue fixed by #64?