vvopensource
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Properties Macros Groups Pages
OSCInPort.h
1 
2 #if IPHONE
3 #import <UIKit/UIKit.h>
4 #else
5 #import <Cocoa/Cocoa.h>
6 #endif
7 
8 #import <VVBasics/VVBasics.h>
9 #import "OSCQueryReply.h"
10 //#import <sys/types.h>
11 //#import <sys/socket.h>
12 #import <netinet/in.h>
13 #import <unistd.h>
14 #import <libkern/OSAtomic.h>
15 #import "OSCPacket.h"
16 #import "OSCBundle.h"
17 #import "OSCMessage.h"
18 #import "OSCOutPort.h"
19 
20 
21 
22 
24 
32 @interface OSCInPort : NSObject {
33  BOOL deleted; // whether or not i'm deleted- ensures that socket gets closed
34  BOOL bound; // whether or not the socket is bound
35  OSSpinLock socketLock;
36  int sock; // socket file descriptor. remember, everything in unix is files!
37  struct sockaddr_in addr; // struct that describes *my* address (this is an in port)
38  unsigned short port; // the port number i'm receiving from
39  unsigned char *buf; // the socket gets data and dumps it here immediately
40  double interval; // how many times/sec you want the thread to run
41 
42  OSSpinLock scratchLock;
43  NSThread *thread;
44  VVStopwatch *timeoutSWatch; // used to check the query dict for timeouts
45  MutLockDict *queryDict; // key is the address of the dispatched query, object is a OSCQueryReply object
46 
47  NSString *portLabel;
48  OSSpinLock zeroConfLock;
49  VVStopwatch *zeroConfSwatch; // bonjour services need ~5 seconds between destroy/creation or the changes get ignored- this is how we track this time
50  NSNetService *zeroConfDest; // bonjour service for publishing this input's address...only active if there's a portLabel!
51 
52  NSMutableArray *scratchArray; // array of OSCMessage objects. used for serial messaging.
53  id delegate;
54 }
55 
56 // Creates and returns an auto-released OSCInPort for the given port (or nil if the port's busy)
57 + (id) createWithPort:(unsigned short)p;
58 // Creates and returns an auto-released OSCInPort for the given port and label (or nil if the port's busy)
59 + (id) createWithPort:(unsigned short)p labelled:(NSString *)n;
60 - (id) initWithPort:(unsigned short)p;
61 - (id) initWithPort:(unsigned short)p labelled:(NSString *)n;
62 
63 - (void) prepareToBeDeleted;
64 
66 - (NSDictionary *) createSnapshot;
67 
68 - (BOOL) createSocket;
69 - (void) start;
70 - (void) stop;
71 - (void) OSCThreadProc;
72 - (void) parseRawBuffer:(unsigned char *)b ofMaxLength:(int)l fromAddr:(unsigned int)txAddr port:(unsigned short)txPort;
73 
75 - (void) handleScratchArray:(NSArray *)a;
77 - (void) _addMessage:(OSCMessage *)val;
78 
79 
80 
82 - (void) dispatchQuery:(OSCMessage *)m toOutPort:(OSCOutPort *)o timeout:(float)t replyHandler:(void (^)(OSCMessage *replyMsg))block;
83 - (void) dispatchQuery:(OSCMessage *)m toOutPort:(OSCOutPort *)o timeout:(float)t replyDelegate:(id <OSCQueryReplyDelegate>)d;
84 
85 // called internally by OSCManager when it's asked to dispatch a query. you should never need to call this method manually.
86 - (void) _dispatchQuery:(OSCMessage *)m toOutPort:(OSCOutPort *)o;
87 
88 
89 
90 - (unsigned short) port;
91 - (void) setPort:(unsigned short)n;
92 - (NSString *) portLabel;
93 - (void) setPortLabel:(NSString *)n;
94 - (NSString *) zeroConfName;
95 - (BOOL) bound;
96 - (NSString *) ipAddressString;
97 
99 - (id) delegate;
101 - (void) setDelegate:(id)n;
103 - (void) setInterval:(double)n;
104 
105 @end
Corresponds to an OSC message: contains zero or more values, and the address path the values have to ...
Definition: OSCMessage.h:18
NSString * portLabel
the "name" of the port (added to distinguish multiple osc input ports for bonjour) ...
Definition: OSCInPort.h:47
OSCInPort handles everything needed to receive OSC data on a given port.
Definition: OSCInPort.h:32
This class is used to measure how long it takes to do things; much easier to work with than NSDate...
Definition: VVStopwatch.h:16
MutLockDict is a thread-safe version of NSMutableDictionary.
Definition: MutLockDict.h:17
OSCOutPort handles everything needed to send OSC data to a given address.
Definition: OSCOutPort.h:25
id delegate
my delegate gets notified of incoming messages
Definition: OSCInPort.h:53