[muscle] Re: muscle client

  • From: "VANHERP Wim" <Wim.VANHERP@xxxxxx>
  • To: <muscle@xxxxxxxxxxxxx>
  • Date: Sat, 28 May 2005 21:54:10 +0200


I see what you mean.  By the way, do you know why there are so many
codes that are translated into HexValues in the mails of your
distributionlist ?  Is there a way to correct this ?

Thanks a lot for your answer, i'm always surprised to notice that people
who write open-software give a better support then companies who sell
Where are you living ? Is it in Canada (that's what i should think when
i see the name of your website).  I'm living in Belgium and working for
the public radiobroadcast.


-----Oorspronkelijk bericht-----
Van: muscle-bounce@xxxxxxxxxxxxx [mailto:muscle-bounce@xxxxxxxxxxxxx]
Namens Jeremy Friesner
Verzonden: vrijdag 27 mei 2005 18:27
Aan: muscle@xxxxxxxxxxxxx
Onderwerp: [muscle] Re: muscle client=20

Hi Wim,

MessageReceivedFromOwner() is called by the network I/O thread, whenever
your main thread calls SendMessageToSessions().  It is involved with
messages going to the server, not messages coming back from the server,
so it is not the method you want to use.

Typically a (Something)MessageTransceiverThread is used like this:

1) Your code creates a (Something)MessageTransceiverThread object, and
calls StartInternalThread() and AddNewConnectSession() on it to connect
to the server.
2) When your code wants to send a Message to the server, it calls
SendMessageToSessions() on the object.
3) When the object receives a Message from the server, it notifies your
code in the main thread that a Message has been received, and your code
will then respond to that notification by running some code like this:

   uint32 code;
   MessageRef msgRef;
&msgRef) =3D3D=3D3D B=3D5FNO=3D5FERROR)
            printf("Hey, I received a Message from the server!  The
Message is:\n");
            if (msgRef()) msgRef()->PrintToStream();

         case MTT=3D5FEVENT=3D5FSESSION=3D5FCONNECTED:    =20
            printf("The TCP connection to the server has been

            printf("The TCP connection to the server has been

So the only question is:  how can the MessageTransceiverThread object
notify your main thread that it is time to execute the above code=3D3F  I=
you were using Microsoft's Win32 API directly, then you could use the
Win32MessageTransceiverThread class to do this; it knows how to notify a
Win32 GUI thread using either the SetEvent() or PostThreadMessage()
Win32 API functions.

However, if you are using the wxWidgets toolkit instead of the Win32 API
directly, you'll=20
probably want/need to use a wxwidgets specific thread-signalling method
instead.  I haven't used wxWidgets myself (I've always used Qt instead),
but from Googling around a bit, it appears that the way to do this would
be to have the MessageTransceiverThread object call wxPostEvent(), and
then your main GUI thread would respond to the received event by
executing the code shown above.

In order to get your MessageTransceiverThread class to do this, you'll
want to use your own wxWindowsMessageTransceiverThread subclass, instead
of using Win32MessageTransceiverThread.  It might look something like

enum {CHECK=3D5FFOR=3D5FNETWORK=3D5FEVENTS =3D3D 123456};  // some event =
that your main thead can recognize

class wxWindowsMessageTransceiverThread : public
MessageTransceiverThread {
   wxWindowsMessageTransceiverThread(wxEvtHandler * target) :
=3D5Ftarget(target) {/* empty */}

   /** Override SignalOwner() to notify the main thread the wxWindows
way! */
   virtual void SignalOwner()
      wxEvent evt(CHECK=3D5FFOR=3D5FNETWORK=3D5FEVENTS);
      ::wxPostEvent(=3D5Ftarget, evt);

   wxEvtHandler * =3D5Ftarget;

If you do it as shown above, then there shouldn't be any problem with
cleanup; just remember to call Reset() on your
wxWindowsMessageTransceiverThread object before you delete it.

Hope that helps,


> I was thinking about a system of using the client of muscle  in the=20
> following way and I would ask if this would have a chance to work. If=20=

> I subclass Win32MessageTransceiverThread to=20
> MyWin32MessageTransceiverThread and I override the virtual function=20
> MessageReceivedFromOwner(MessageRef msgRef, uint32 numLeft) I have a=20=

> function that  will be called every time when a new message arrives,=20=

> my first idea was to use this message directly, but I think there will

> be a problem in cleaning up the message afterwards, so maybe it is=20
> possible to call GetNextEventFromInternalThread in this overloaded=20
> function and do the things I want to do ( in fact create a wxwidgets=20=

> event). Is it correct what I'm thinking  =3D3F

*** Disclaimer ***

Deze e-mail, met eventuele bijlagen, is alleen bestemd voor de persoon of=
 organisatie aan wie hij gericht is en, in voorkomend geval, alleen voor =
het daarin opgegeven doel of gebruik. Hij kan vertrouwelijke informatie b=
evatten en/of persoonlijke standpunten die niet noodzakelijk met die van =
de VRT stroken. Elk gebruik van deze informatie (zoals bewerken, doorstur=
en, geheel of gedeeltelijk reproduceren of verspreiden in welke vorm ook)=
 door anderen dan de geadresseerde, is verboden. Hebt U deze e-mail per v=
ergissing ontvangen, meld dat dan a.u.b. aan de VRT en wis de e-mail.

Other related posts: