Skip to content

Commit a11d117

Browse files
committed
work on framework
slight API change, the remote server object now supports multiple delegates. disabled websocket++ logging. fixed bug with the server that resulted in a crash when a client was disconnecting under some specific circumstances
1 parent 0b2e3b5 commit a11d117

19 files changed

+185
-75
lines changed

LiveOSCQueryHelper/LiveOSCQueryHelperAppDelegate.m

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -209,7 +209,7 @@ - (void) _loadAbletonProjectFile:(NSString *)fullPath {
209209
NSString *fileName = [[fullPath lastPathComponent] stringByDeletingPathExtension];
210210
[server setName:fileName];
211211
NSString *bjName = [NSString stringWithFormat:@"%@ OSCQuery Helper",fileName];
212-
int nameLength = [bjName length];
212+
int nameLength = (int)[bjName length];
213213
if (nameLength > 63) {
214214
bjName = [NSString stringWithFormat:@"%@...%@",[bjName substringWithRange:NSMakeRange(0,30)],[bjName substringWithRange:NSMakeRange(nameLength-30,30)]];
215215
}
@@ -304,7 +304,7 @@ - (void) _loadAbletonProjectFile:(NSString *)fullPath {
304304
NSString *objDesc = [baseObj objectForKey:kVVOSCQ_ReqAttr_Desc];
305305
NSArray *objTags = [baseObj objectForKey:kVVOSCQ_OptAttr_Tags];
306306
NSArray *objExtType = [baseObj objectForKey:kVVOSCQ_OptAttr_Ext_Type]; // one for each type from the type tag string
307-
NSNumber *objAccess = [baseObj objectForKey:kVVOSCQ_OptAttr_Access];
307+
//NSNumber *objAccess = [baseObj objectForKey:kVVOSCQ_OptAttr_Access];
308308
NSArray *objRange = [baseObj objectForKey:kVVOSCQ_OptAttr_Range]; // one for each type from the type tag string
309309
NSArray *objUnits = [baseObj objectForKey:kVVOSCQ_OptAttr_Unit]; // one for each type from the type tag string
310310
NSNumber *objCritical = [baseObj objectForKey:kVVOSCQ_OptAttr_Critical];

MIDIOSCQueryHelper/MIDIOSCQueryHelperAppDelegate.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -198,7 +198,6 @@ - (void) _loadLastFile {
198198
NSString *tmpString = [def objectForKey:@"lastOpenDocumentFile"];
199199
// if there's no default, try to find the sample document we include and use that
200200
if (tmpString == nil) {
201-
NSFileManager *fm = [NSFileManager defaultManager];
202201
NSString *samplePath = [@"~/Documents/MIDI OSCQuery Helper/SampleDocument.json" stringByExpandingTildeInPath];
203202
if ([[NSFileManager defaultManager] fileExistsAtPath:samplePath])
204203
tmpString = samplePath;
@@ -258,7 +257,7 @@ - (void) _loadJSONFile:(NSString *)fullPath {
258257
NSString *fileName = [[fullPath lastPathComponent] stringByDeletingPathExtension];
259258
[server setName:fileName];
260259
NSString *bjName = [NSString stringWithFormat:@"%@ OSCQuery Helper",fileName];
261-
int nameLength = [bjName length];
260+
int nameLength = (int)[bjName length];
262261
if (nameLength > 63) {
263262
bjName = [NSString stringWithFormat:@"%@...%@",[bjName substringWithRange:NSMakeRange(0,30)],[bjName substringWithRange:NSMakeRange(nameLength-30,30)]];
264263
}

OSCQueryHelper/OSCQueryHelperAppDelegate.m

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,7 +200,6 @@ - (void) _loadLastFile {
200200
NSString *tmpString = [def objectForKey:@"lastOpenDocumentFile"];
201201
// if there's no default, try to find the sample document we include and use that
202202
if (tmpString == nil) {
203-
NSFileManager *fm = [NSFileManager defaultManager];
204203
NSString *samplePath = [@"~/Documents/OSCQuery Helper/SampleDocument.json" stringByExpandingTildeInPath];
205204
if ([[NSFileManager defaultManager] fileExistsAtPath:samplePath])
206205
tmpString = samplePath;
@@ -261,7 +260,7 @@ - (void) _loadJSONFile:(NSString *)fullPath {
261260
NSString *fileName = [[fullPath lastPathComponent] stringByDeletingPathExtension];
262261
[server setName:fileName];
263262
NSString *bjName = [NSString stringWithFormat:@"%@ OSCQuery Helper",fileName];
264-
int nameLength = [bjName length];
263+
int nameLength = (int)[bjName length];
265264
if (nameLength > 63) {
266265
bjName = [NSString stringWithFormat:@"%@...%@",[bjName substringWithRange:NSMakeRange(0,30)],[bjName substringWithRange:NSMakeRange(nameLength-30,30)]];
267266
}

VVOSCQueryBrowser/RemoteNode.m

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,19 @@ - (id) initWithParent:(RemoteNode *)p dict:(NSDictionary *)d {
450450
[contents addObject:newNode];
451451
}
452452
}];
453+
[contents sortUsingComparator:(NSComparator)^(id obj1, id obj2) {
454+
NSString *str1 = nil;
455+
NSString *str2 = nil;
456+
if ([obj1 isKindOfClass:[RemoteNode class]])
457+
str1 = [obj1 name];
458+
else
459+
str1 = [NSString stringWithFormat:@"%@-%d",[[obj1 parentNode] name],[(RemoteNodeControl*)obj1 index]];
460+
if ([obj2 isKindOfClass:[RemoteNode class]])
461+
str2 = [obj2 name];
462+
else
463+
str2 = [NSString stringWithFormat:@"%@-%d",[[obj2 parentNode] name],[(RemoteNodeControl*)obj2 index]];
464+
return [str1 caseInsensitiveCompare:str2];
465+
}];
453466
}
454467
return self;
455468
}

VVOSCQueryBrowser/RemoteNodeControl.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,7 @@ case 'I':
6262

6363
@property (weak) RemoteNode * parentNode;
6464
//@property (assign) int index;
65+
@property (readonly) int index;
6566
@property (strong) NSString * typeString;
6667
@property (strong) OSCValue * value;
6768
@property (strong) OSCValue * min;

VVOSCQueryBrowser/RemoteNodeControl.m

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,9 @@ - (NSString *) outlineViewIdentifier {
8181

8282

8383
@synthesize parentNode;
84+
- (int) index {
85+
return (parentNode==nil) ? 0 : (int)[parentNode indexOfControl:self];
86+
}
8487
@synthesize typeString;
8588
@synthesize value;
8689
@synthesize min;

VVOSCQueryBrowser/ServerUIController.m

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -112,11 +112,11 @@ - (void) newServerChosen:(VVOSCQueryRemoteServer*)n {
112112
return;
113113

114114
// resign as delegate from my existing server
115-
[server setDelegate:nil];
115+
[server removeDelegate:self];
116116

117117
// update my server, sign up as its delegate
118118
server = n;
119-
[server setDelegate:self];
119+
[server addDelegate:self];
120120

121121
// do a full reload (reload the expand states too)
122122
[self fullReloadData];
@@ -170,7 +170,7 @@ - (void) remoteServerWentOffline:(VVOSCQueryRemoteServer *)remoteServer {
170170
}
171171
- (void) remoteServer:(VVOSCQueryRemoteServer *)remoteServer websocketDeliveredJSONObject:(NSDictionary *)jsonObj {
172172
NSLog(@"%s ... %@",__func__,jsonObj);
173-
NSLog(@"\t\tshould be checking for and handling PATH_CHANGED here, %s",__func__);
173+
//NSLog(@"\t\tshould be checking for and handling PATH_CHANGED here, %s",__func__);
174174
}
175175
- (void) remoteServer:(VVOSCQueryRemoteServer *)remoteServer receivedOSCPacket:(const void *)packet sized:(size_t)packetSize {
176176
//NSLog(@"%s ... %p, %ld",__func__,packet,packetSize);
@@ -439,6 +439,7 @@ - (void) fullReloadData {
439439
}
440440
[self reloadRemoteNodes];
441441
[uiItemOutlineView reloadData];
442+
[uiItemOutlineView expandItem:nil expandChildren:YES];
442443
}
443444

444445

VVOSCQueryClient/OSCQueryProtocolClientAppDelegate.m

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ - (void) coalescingTimerCallback:(NSTimer *)t {
7474
[displayString appendFormat:@"%d servers detected:\n",(servers==nil) ? 0 : (int)[servers count]];
7575
[displayString appendFormat:@"**************\n"];
7676
for (VVOSCQueryRemoteServer *server in servers) {
77-
[server setDelegate:self];
77+
[server addDelegate:self];
7878
[displayString appendFormat:@"name: \"%@\"\n",[server oscName]];
7979
[displayString appendFormat:@"\tbonjour: \"%@\"\n",[server bonjourName]];
8080
[displayString appendFormat:@"\taddress: %@:%d\n",[server webServerAddressString],[server webServerPort]];

VVOSCQueryProtocol.xcodeproj/project.pbxproj

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
/* End PBXAggregateTarget section */
2828

2929
/* Begin PBXBuildFile section */
30+
1A0B5F55203E0EC800948FDA /* ZWRObject.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A0B5F53203E0EC800948FDA /* ZWRObject.m */; };
31+
1A0B5F56203E0EC800948FDA /* ZWRObject.h in Headers */ = {isa = PBXBuildFile; fileRef = 1A0B5F54203E0EC800948FDA /* ZWRObject.h */; };
3032
1A0E2F361FD6D3CB00F0855D /* VVOSCQueryBrowserAppDelegate.m in Sources */ = {isa = PBXBuildFile; fileRef = 1A0E2F351FD6D3CB00F0855D /* VVOSCQueryBrowserAppDelegate.m */; };
3133
1A0E2F381FD6D3CB00F0855D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 1A0E2F371FD6D3CB00F0855D /* Assets.xcassets */; };
3234
1A0E2F3B1FD6D3CB00F0855D /* MainMenu.xib in Resources */ = {isa = PBXBuildFile; fileRef = 1A0E2F391FD6D3CB00F0855D /* MainMenu.xib */; };
@@ -347,6 +349,8 @@
347349
/* End PBXCopyFilesBuildPhase section */
348350

349351
/* Begin PBXFileReference section */
352+
1A0B5F53203E0EC800948FDA /* ZWRObject.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = ZWRObject.m; sourceTree = "<group>"; };
353+
1A0B5F54203E0EC800948FDA /* ZWRObject.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = ZWRObject.h; sourceTree = "<group>"; };
350354
1A0E2F321FD6D3CB00F0855D /* OSCQuery Browser.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "OSCQuery Browser.app"; sourceTree = BUILT_PRODUCTS_DIR; };
351355
1A0E2F341FD6D3CB00F0855D /* VVOSCQueryBrowserAppDelegate.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = VVOSCQueryBrowserAppDelegate.h; sourceTree = "<group>"; };
352356
1A0E2F351FD6D3CB00F0855D /* VVOSCQueryBrowserAppDelegate.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = VVOSCQueryBrowserAppDelegate.m; sourceTree = "<group>"; };
@@ -764,6 +768,8 @@
764768
1AF1087C1FCDD7F3004566A8 /* internal */ = {
765769
isa = PBXGroup;
766770
children = (
771+
1A0B5F54203E0EC800948FDA /* ZWRObject.h */,
772+
1A0B5F53203E0EC800948FDA /* ZWRObject.m */,
767773
1A906E7E1FCC8D1700F0E412 /* NSNetServiceAdditions.h */,
768774
1A906E7F1FCC8D1700F0E412 /* NSNetServiceAdditions.m */,
769775
1AF108781FCDC509004566A8 /* NSStringAdditions.h */,
@@ -803,6 +809,7 @@
803809
1AF108761FCD9DC0004566A8 /* CURLDL.h in Headers */,
804810
1A906E801FCC8D1700F0E412 /* NSNetServiceAdditions.h in Headers */,
805811
1A336E941FC871900007877C /* VVOSCQueryRemoteServer.h in Headers */,
812+
1A0B5F56203E0EC800948FDA /* ZWRObject.h in Headers */,
806813
1AB89C311FD1EE1B0094A66B /* WSPPServer.hpp in Headers */,
807814
1AB4FB2C1FCC6C91005E3028 /* VVOSCQueryServerDetectorDomain.h in Headers */,
808815
1A480FE51FCAD55D00F86354 /* VVOSCQueryServerDetector.h in Headers */,
@@ -1152,6 +1159,7 @@
11521159
1AB89C301FD1EE1B0094A66B /* WSPPServer.cpp in Sources */,
11531160
1A480FDE1FC89A9D00F86354 /* VVOSCQueryReply.m in Sources */,
11541161
1AF108771FCD9DC0004566A8 /* CURLDL.m in Sources */,
1162+
1A0B5F55203E0EC800948FDA /* ZWRObject.m in Sources */,
11551163
1A7C48F61FD586DB00AE4287 /* VVOSCQueryStringUtilities.cpp in Sources */,
11561164
1A336E911FC871870007877C /* VVOSCQueryServer.mm in Sources */,
11571165
1A336E951FC871900007877C /* VVOSCQueryRemoteServer.mm in Sources */,

VVOSCQueryProtocol/VVOSCQueryRemoteServer.h

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -55,11 +55,7 @@
5555
NSString *wsServerAddressString;
5656
int wsServerPort;
5757

58-
#if __has_feature(objc_arc)
59-
__weak id<VVOSCQueryRemoteServerDelegate> delegate;
60-
#else
61-
id<VVOSCQueryRemoteServerDelegate> delegate;
62-
#endif
58+
NSMutableArray *delegateRefs; // array of ZWRObject instances, each instance is a zeroing weak ref to a delegate
6359
}
6460

6561
// you should try to avoid retaining any of these remote servers- use a weak ref if you want to store a ptr to one of them.
@@ -87,12 +83,10 @@
8783
@property (readonly) NSString *wsServerAddressString;
8884
@property (readonly) int wsServerPort;
8985

90-
// the delegate is notified if the remote server goes offline. the delegate is also notified if the server delivers a JSON blob over the websocket connection.
91-
#if __has_feature(objc_arc)
92-
@property (weak) id<VVOSCQueryRemoteServerDelegate> delegate;
93-
#else
94-
@property (assign) id<VVOSCQueryRemoteServerDelegate> delegate;
95-
#endif
86+
// delegates are informed of a variety of server events, including path add/remove/change callbacks, OSC packets delivered over the websocket connection, other miscellaneous websocket data, and offline callbacks
87+
- (void) addDelegate:(id<VVOSCQueryRemoteServerDelegate>)n;
88+
- (void) removeDelegate:(id<VVOSCQueryRemoteServerDelegate>)n;
89+
- (NSArray *) delegateRefs;
9690

9791
// synchronous- queries the remote server for its host info
9892
- (NSDictionary *) hostInfo;

0 commit comments

Comments
 (0)