User Tag List

Page 5 of 6 FirstFirst ... 3 4 5 6 LastLast
Results 41 to 50 of 59

Thread: Binary messages

  1. #41
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Stack messages

    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.
    Working as fast as I can on Fusion 3

  2. #42
    Clicker Multimedia Fusion 2
    Greg's Avatar
    Join Date
    Dec 2006
    Location
    Poland
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Stack messages

    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

  3. #43
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Stack messages

    On the Sender's Side:
    Push Byte (some value) onto stack
    Push Short (some value) onto stack

    On the Receiver's Side:
    Get Byte (signed/unsigned) at 0
    Get Short (signed/unsigned) at 1
    Working as fast as I can on Fusion 3

  4. #44
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Stack messages

    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.

  5. #45
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

    Join Date
    Jun 2006
    Posts
    6,773
    Mentioned
    1 Post(s)
    Tagged
    0 Thread(s)

    Re: Stack messages

    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 Originally Posted by Greg
    Jamie, could you please tell me how can I send a stack message with one byte and one short in C++?
    Code:
    char Message[3];
    
    *(char *) Message = TheByte;
    *(short *) (Message + 1) = TheShort;
    
    Channel.Send(Subchannel, Message, 3, 2);

  6. #46
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Stack messages

    Given that, this might be safer:
    Code:
    In 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.

  7. #47
    Clicker Multimedia Fusion 2
    Greg's Avatar
    Join Date
    Dec 2006
    Location
    Poland
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Stack 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

  8. #48
    Clicker Multimedia Fusion 2
    Greg's Avatar
    Join Date
    Dec 2006
    Location
    Poland
    Posts
    315
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Stack messages

    Jamie, how about sending a string in a stack? I've tried this:
    Code:
    char Message[3];
    string s = "abc";
    
    *(string*)Message = s;
    ...but the app crashes then. I've also tried:
    Code:
    char Message[3];
    string s = "abc";
    
    (string)Message = s;
    But it doesn't work either.

  9. #49
    Clickteam Clickteam
    LB's Avatar
    Join Date
    Jun 2007
    Location
    Richardson, Texas, North America
    Posts
    8,937
    Mentioned
    3 Post(s)
    Tagged
    0 Thread(s)

    Re: Stack messages

    Don't forget that strings are null terminated, so "abc" is actually a b c \0
    Working as fast as I can on Fusion 3

  10. #50
    Clicker Multimedia Fusion 2 Developer

    Join Date
    Jun 2006
    Location
    Darlington, UK
    Posts
    3,298
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Re: Stack messages

    You can probably do:
    string s = "abc";
    Channel.Send(Subchannel, s.c_str(), s.size(), 2);

Page 5 of 6 FirstFirst ... 3 4 5 6 LastLast

Similar Threads

  1. RPG-like Text Messages
    By Corlen in forum Multimedia Fusion 2 - Technical Support
    Replies: 0
    Last Post: 9th June 2012, 03:18 PM
  2. Help Messages
    By Pixzel in forum Multimedia Fusion 2 - Technical Support
    Replies: 1
    Last Post: 25th March 2011, 10:43 PM
  3. Sphax Messages Box
    By Jeff in forum Released Extensions
    Replies: 3
    Last Post: 9th April 2009, 10:14 AM
  4. Encrypting messages in Moo
    By Plooscva in forum Multimedia Fusion 2 - Technical Support
    Replies: 6
    Last Post: 24th February 2007, 11:49 AM
  5. Messages Box object - Bug
    By Gustav in forum File Archive
    Replies: 9
    Last Post: 26th November 2006, 03:29 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •