forked from a1anyip/libobjcipc
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathConnection.h
More file actions
81 lines (64 loc) · 2.28 KB
/
Connection.h
File metadata and controls
81 lines (64 loc) · 2.28 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
//
// libobjcipc
// Connection.h
//
// Created by Alan Yip on 6 Feb 2014
// Copyright 2014 Alan Yip. All rights reserved.
//
#import "header.h"
@interface OBJCIPCConnection : NSObject<NSStreamDelegate> {
BOOL _closedConnection;
BOOL _handshakeFinished;
NSString *_appIdentifier;
NSUInteger _nextMessageIdentifier;
// auto disconnect
NSUInteger _autoDisconnectTimerTicks;
NSTimer *_autoDisconnectTimer;
// socket streams
NSInputStream *_inputStream;
NSOutputStream *_outputStream;
// header
BOOL _receivedHeader;
int _receivedHeaderLength;
BOOL _isHandshake;
BOOL _isReply;
NSString *_messageIdentifier;
NSString *_messageName;
NSMutableData *_receivedHeaderData;
// content
int _contentLength;
int _receivedContentLength;
NSMutableData *_receivedContentData;
// temporary storage of outgoing message data
NSMutableData *_outgoingMessageData;
// pending incoming messages (received earlier than handshake)
NSMutableArray *_pendingIncomingMessages;
// incoming message handler
NSMutableDictionary *_incomingMessageHandlers;
NSMutableDictionary *_replyHandlers;
}
@property(nonatomic, copy) NSString *appIdentifier;
@property(nonatomic, readonly) NSMutableDictionary *incomingMessageHandlers;
@property(nonatomic, retain) NSMutableDictionary *replyHandlers;
- (instancetype)initWithInputStream:(NSInputStream *)inputStream outputStream:(NSOutputStream *)outputStream;
- (void)sendMessage:(OBJCIPCMessage *)message;
- (void)closeConnection;
- (void)setIncomingMessageHandler:(OBJCIPCIncomingMessageHandler)handler forMessageName:(NSString *)messageName;
- (OBJCIPCIncomingMessageHandler)incomingMessageHandlerForMessageName:(NSString *)messageName;
- (NSString *)nextMessageIdentifier;
// handshake with app and SpringBoard
- (void)_handshakeWithSpringBoard;
- (void)_handshakeWithSpringBoardComplete:(NSDictionary *)dict;
- (NSDictionary *)_handshakeWithApp:(NSDictionary *)dict;
// message data transmission
- (void)_readIncomingMessageData;
- (void)_writeOutgoingMessageData;
- (void)_dispatchReceivedMessage;
- (void)_dispatchIncomingMessage:(NSDictionary *)dictionary;
- (void)_resetReceivingMessageState;
// auto disconnect
- (void)_createAutoDisconnectTimer;
- (void)_resetAutoDisconnectTimer;
- (void)_triggerAutoDisconnect;
- (void)_invalidateAutoDisconnectTimer;
@end