User Tag List

Page 4 of 5 FirstFirst ... 2 3 4 5 LastLast
Results 31 to 40 of 50

Thread: Lacewing Build #19

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

    Re: Lacewing Build #19

    I've got yet another question:
    How do I start a new thread in the new Lacewing? In build #17 I had a line:
    Code:
    Lacewing::Utility::StartThread(ping, &Server);
    And what's the difference between starting a thread in Lacewing and starting a thread in C/C++?

  2. #32
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

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

    Re: Lacewing Build #19

    The thread functionality is a class now:

    Code:
    Lacewing::Thread MyThread ("Some Name", YourThreadFunction);
    MyThread.Start (SomeParameter);
    The difference is that C/C++ has no facility for starting threads. Lacewing uses whatever functionality is provided by the operating system (WINAPI, or pthread on Unix).

    I hope you're aware that most of the liblacewing classes aren't thread safe! Maybe you should consider using something like Lacewing::Timer (if possible) rather than a thread. Failing that, use the EventPump Post() method to run code at a safe time in Lacewing's event loop.

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

    Re: Lacewing Build #19

    Thanks for the quick reply, as always

    I had no idea, thanks for letting me know You mean something like this?
    Code:
    void onTick (Lacewing::Timer &Timer)
    {
       //Ping all clients
    }
    
    Lacewing::EventPump TimerPump;
    Lacewing::Timer Timer(TimerPump);
    Timer.onTick(onTick);
    Timer.Start(30000);
    To ping each 30 seconds?

  4. #34
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

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

    Re: Lacewing Build #19

    Both the Server and the Timer should share the same EventPump, but otherwise, yes.

    Did you know that the protocol has pinging built in to detect lost connections?

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

    Re: Lacewing Build #19

    Really? Is that some class I need to use or is pinging done automatically?

  6. #36
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

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

    Re: Lacewing Build #19

    It's automatic!

    By the way, the correct usage of the EventPump in a console application:

    Code:
    int main (int argc, char * argv [])
    {
        Lacewing::EventPump EventPump;
    
        /* Create any classes you want to use, passing EventPump to the constructor.  Example: */
    
        Lacewing::RelayServer Server (EventPump);
        Server.Host ();
    
        /* This function will not return.  Internally, it will loop forever,
           letting the other classes know when a socket is ready etc. */
    
        EventPump.StartEventLoop ();
    
        return 0;
    }

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

    Re: Lacewing Build #19

    Wow, that's great! Lacewing keeps surprising me
    And thanks for the code sample

    Sorry for bothering, but I've got YET another question xD
    Could you please give me a sample code on how to iterate through all clients in the server/channel?

  8. #38
    Clicker Multimedia Fusion 2 DeveloperSWF Export Module

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

    Re: Lacewing Build #19

    No bother at all! :-)

    Iterating through all clients on the server:

    Code:
    for (Lacewing::RelayServer::Client * Client = Server.FirstClient ();
                    Client; Client = Client->Next ())
          {
               printf ("Client %s is present\n", Client->Name ());
          }
    Iterating through all clients on a channel:

    Code:
    Lacewing::RelayServer::Channel::ClientIterator Iterator (Channel);
    
    for (Lacewing::RelayServer::Client * Client = Iterator.Next ();
                Client; Client = Iterator.Next ())
        {
            printf ("Client %s is in the channel\n", Client->Name ());
        }
    If you get any "unresolved external symbol" errors with this code, grab the edge liblacewing source from here.

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

    Re: Lacewing Build #19

    Thanks again! I'm sure it's gonna be helpful, not only for me

    EDIT:
    I had the "unresolved external" problem and compiled the source you gave me and it compiled correctly. Do I need to use that *.DLL too?

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

    Re: Lacewing Build #19

    Sorry for the double post, but it's a different thing now. There seems to be a bug in the Relay Client for MMF. The function "StringWithSize$" takes only one parameter - the index. Shouldn't it also take the size?

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

Similar Threads

  1. Lacewing Build #20
    By James in forum Lacewing
    Replies: 73
    Last Post: 13th July 2015, 02:14 PM
  2. Lacewing Build 18
    By DJ_Wild in forum Multimedia Fusion 2 - Technical Support
    Replies: 2
    Last Post: 31st July 2011, 05:47 PM
  3. Lacewing Build #17
    By James in forum Lacewing
    Replies: 69
    Last Post: 18th June 2011, 07:31 PM
  4. Lacewing Build 14
    By James in forum Lacewing
    Replies: 76
    Last Post: 4th April 2011, 11:17 PM
  5. Lacewing Build 13
    By James in forum Lacewing
    Replies: 31
    Last Post: 3rd May 2010, 06:16 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
  •