If you want I could send you my File Sender source code. I am too lazy to make an example within a timespan that will suit you, but I will soon. PM me if you want my source.
Binary messages
Welcome to our brand new Clickteam Community Hub! We hope you will enjoy using the new features, which we will be further expanding in the coming months.
A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.
Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!
Clickteam.
A few features including Passport are unavailable initially whilst we monitor stability of the new platform, we hope to bring these online very soon. Small issues will crop up following the import from our old system, including some message formatting, translation accuracy and other things.
Thank you for your patience whilst we've worked on this and we look forward to more exciting community developments soon!
Clickteam.
-
-
Jamie, could you please tell me how can I send a stack message with one byte and one short in C++?
I've tried to figure it out myself, but it always seems to lost the last value. For example, if I send a stack with char and short, then MMF reads the char, but it can't read the short properly. And if I send a stack with short and char, then it can read the short, but can't read the char...
I'm sure I'm doing something wrong, so please show me some example on how to do it -
On the Sender's Side:
Push Byte (some value) onto stack
Push Short (some value) onto stackOn the Receiver's Side:
Get Byte (signed/unsigned) at 0
Get Short (signed/unsigned) at 1 -
In C++ LB...
EDIT: My guess is that the C++ version of lacewing needs you to send the whole stack in one go, not push element by element. Best wait for Jamie to be sure.
-
The whole stack/text/number message system is an MMF2 thing. C++ Lacewing just transmits binary buffers with a subchannel and type (0-8). The MMF2 extension uses type 0 for text (ASCII char array), 1 for number (4 byte integer) and 2 for a stack (little endian binary buffer).
Quote from GregJamie, could you please tell me how can I send a stack message with one byte and one short in C++?
-
Given that, this might be safer:
Code
Display MoreIn a header: #pragma pack (push, 1) struct Message { char theByte; short theShort; }; #pragma pack (pop) When sending: Message message; message.theByte = TheByte; message.theShort = TheShort; Channel.Send(Subchannel, &message, sizeof(message), 2);
It looks more longwinded, but it's safe against sizing errors, and it's much easier to add to the message. Obviously you'd name "struct Message", "Message::theByte", and "Message::theShort" more sensibly, and have different structs for different messages.
-
Thanks, Jamie, now I know how it works I've never seen something like *(short*) (Message+1), I wouldn't figure it out by myself xD
-
-
Don't forget that strings are null terminated, so "abc" is actually a b c \0
-
You can probably do:
string s = "abc";
Channel.Send(Subchannel, s.c_str(), s.size(), 2); -
Dynasoft, your solution works, but only if the string is the only thing I send in the stack. I need to send it along with some char and short values.
EDIT:
Nvm, I've already figured it out! Thanks! -
Jamie,
Could you post an example of how to send a file using lacewing. I tried doing it, and I get the file, but the file that is sent returns 0 kb with no data.
I am confused about position and size.
-
Position is the position in the stack, which normally is 0 if you are only sending file data, and the size you can get via an expression to get the size of the stack. The easiest thing to do is to create the file with the File Object, then use Lacewing's Append Stack to File action. You can send large files in small chunks, too, which should be some simple math
-
LB, thanks man.
I will try it out and see if it works. But now it makes sense to me.
-Mike
-
Hello,
I have a very strange bug.
I try to send (X,Y) to the channel via Stacks, but when the other client received the stack, X is set correctly but Y takes a strange value.
Please login to see this picture.
-
You are reading the short from 1, when really it is at 2. A short has two bytes worth of data. Just change the second parameter to two, where you are changing the Y position, and it should work fine.
-
Thank you it works fine.
Can you explain me why "A short has two bytes worth of data" ?
Edit : I understood Thanks !!!
-
Jamie, thanks for this! Since Flash isn't capable of UDP, stacks will help quite a bit (I hope!).
-
That really helped.
It would be nice if the tutorial could be updated. The whole "push" thing confused mein the start.
-
Participate now!
Don’t have an account yet? Register yourself now and be a part of our community!