3 Copyright (C) 2011 Grame
5 This library is free software; you can redistribute it and/or
6 modify it under the terms of the GNU Lesser General Public
7 License as published by the Free Software Foundation; either
8 version 2.1 of the License, or (at your option) any later version.
10 This library is distributed in the hope that it will be useful,
11 but WITHOUT ANY WARRANTY; without even the implied warranty of
12 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13 Lesser General Public License for more details.
15 You should have received a copy of the GNU Lesser General Public
16 License along with this library; if not, write to the Free Software
17 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
19 Grame Research Laboratory, 9 rue du Garet, 69001 Lyon - France
25 #ifndef __OSCListener__
26 #define __OSCListener__
28 #include "smartpointer.h"
29 #include "MessageProcessor.h"
31 // oscpack include files
32 #include "ip/UdpSocket.h"
33 #include "osc/OscPacketListener.h"
38 //--------------------------------------------------------------------------
40 \brief an OSC listener that converts OSC input to Messages
42 OSCListener makes the glue between the oscpack library
43 and the faust lib osc messages representation
44 \see Message in Message.h
46 class OSCListener
: public osc::OscPacketListener
, public smartable
48 UdpListeningReceiveSocket
*fSocket
; ///< the udp socket listener
49 MessageProcessor
* fMsgHandler
;
54 static SMARTP
<OSCListener
> create(MessageProcessor
* mp
, int port
)
55 { return new OSCListener(mp
, port
); }
58 \brief process OSC messages
60 \param m the OSC message (pre-processed by the base class)
61 \param remoteEndpoint the sender IP address
63 virtual void ProcessMessage( const osc::ReceivedMessage
& m
, const IpEndpointName
& remoteEndpoint
);
65 virtual void stop() { fRunning
=false; if (fSocket
) fSocket
->AsynchronousBreak(); }
66 virtual void setPort(int port
) { fPort
= port
; }
67 virtual void restart(int port
) { fPort
= port
; if (fSocket
) fSocket
->AsynchronousBreak(); }
70 OSCListener(MessageProcessor
* mp
, int port
);
71 virtual ~OSCListener();
74 typedef class SMARTP
<OSCListener
> SOSCListener
;