-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
6 changed files
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
app_key.c | ||
config.h |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// ZmqDispatch.h | ||
// CoccoaSpotbox | ||
// | ||
// Created by Tony Schneider on 3/8/12. | ||
// Copyright (c) 2012 Edgecase. All rights reserved. | ||
// | ||
|
||
#import <Foundation/Foundation.h> | ||
|
||
@interface ZmqDispatch : NSObject | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
// | ||
// ZmqDispatch.m | ||
// CoccoaSpotbox | ||
// | ||
// Created by Tony Schneider on 3/8/12. | ||
// Copyright (c) 2012 Edgecase. All rights reserved. | ||
// | ||
|
||
#import "ZmqDispatch.h" | ||
|
||
@implementation ZmqDispatch | ||
|
||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
#import <Foundation/Foundation.h> | ||
#import "ZMQSocket.h" // ZMQSocketType | ||
#import <libkern/OSAtomic.h> | ||
|
||
/* Special polling timeout values. */ | ||
#define ZMQPollTimeoutNever (-1) | ||
#define ZMQPollTimeoutNow (0) | ||
|
||
@interface ZMQContext : NSObject { | ||
void *context; | ||
NSMutableArray *sockets; | ||
OSSpinLock socketsLock; | ||
BOOL terminated; | ||
} | ||
+ (void)getZMQVersionMajor:(int *)major minor:(int *)minor patch:(int *)patch; | ||
|
||
/* Polling */ | ||
// Generic poll interface. | ||
+ (int)pollWithItems:(zmq_pollitem_t *)ioItems count:(int)itemCount | ||
timeoutAfterUsec:(long)usec; | ||
|
||
// Creates a ZMQContext using |threadCount| threads for I/O. | ||
- (id)initWithIOThreads:(NSUInteger)threadCount; | ||
|
||
- (ZMQSocket *)socketWithType:(ZMQSocketType)type; | ||
// Sockets associated with this context. | ||
@property(readonly, retain, NS_NONATOMIC_IPHONEONLY) NSArray *sockets; | ||
|
||
// Closes all associated sockets. | ||
- (void)closeSockets; | ||
|
||
// Initiates termination. All associated sockets will be shut down. | ||
- (void)terminate; | ||
|
||
// YES if termination has been initiated. | ||
// KVOable. | ||
@property(readonly, getter=isTerminated, NS_NONATOMIC_IPHONEONLY) | ||
BOOL terminated; | ||
@end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
/* Convenience header - imports all ZMQObjc headers. */ | ||
#import "ZMQContext.h" | ||
#import "ZMQSocket.h" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
#import <Foundation/Foundation.h> | ||
#import <zmq.h> | ||
@class ZMQContext; | ||
|
||
typedef int ZMQSocketType; | ||
typedef int ZMQSocketOption; | ||
typedef int ZMQMessageSendFlags; | ||
typedef int ZMQMessageReceiveFlags; | ||
|
||
@interface ZMQSocket : NSObject { | ||
void *socket; | ||
ZMQContext *context; // not retained | ||
NSString *endpoint; | ||
ZMQSocketType type; | ||
BOOL closed; | ||
} | ||
// Returns @"ZMQ_PUB" for ZMQ_PUB, for example. | ||
+ (NSString *)nameForSocketType:(ZMQSocketType)type; | ||
|
||
// Create a socket using -[ZMQContext socketWithType:]. | ||
@property(readonly, assign, NS_NONATOMIC_IPHONEONLY) ZMQContext *context; | ||
@property(readonly, NS_NONATOMIC_IPHONEONLY) ZMQSocketType type; | ||
|
||
- (void)close; | ||
// KVOable. | ||
@property(readonly, getter=isClosed, NS_NONATOMIC_IPHONEONLY) BOOL closed; | ||
@property(readonly, copy, NS_NONATOMIC_IPHONEONLY) NSString *endpoint; | ||
|
||
#pragma mark Socket Options | ||
- (BOOL)setData:(NSData *)data forOption:(ZMQSocketOption)option; | ||
- (NSData *)dataForOption:(ZMQSocketOption)option; | ||
|
||
#pragma mark Endpoint Configuration | ||
- (BOOL)bindToEndpoint:(NSString *)endpoint; | ||
- (BOOL)connectToEndpoint:(NSString *)endpoint; | ||
|
||
#pragma mark Communication | ||
- (BOOL)sendData:(NSData *)messageData withFlags:(ZMQMessageSendFlags)flags; | ||
- (NSData *)receiveDataWithFlags:(ZMQMessageReceiveFlags)flags; | ||
|
||
#pragma mark Polling | ||
- (void)getPollItem:(zmq_pollitem_t *)outItem forEvents:(short)events; | ||
@end |