CjConnectivity
CjConnectivityInterface.h
1 //
2 // CjConnectivityInterface.h
3 // CjConnectivity
4 //
5 // Created by C J on 2/4/20.
6 // Copyright © 2020 Seajei, LLC. All rights reserved.
7 //
8 
9 #import <Foundation/Foundation.h>
10 
11 NS_ASSUME_NONNULL_BEGIN
12 
13 @protocol CjConnectivityDelegate;
14 
15 @interface CjConnectivity : NSObject
16 
20 typedef NS_ENUM(NSInteger, CoConnectionEvent) {
37 
38 };
39 
40 typedef NS_ENUM(NSInteger, CoDataType) {
41  CoDataTypeNone,
42  CoDataTypeVideo,
43  CoDataTypeAudio,
44  CoDataTypeOther
45 };
46 
50 typedef NS_ENUM(NSInteger, CoConnectionType) {
56 };
57 
61 typedef NS_ENUM(NSInteger, CoError) {
62  CoSuccess = 0,
63  CoFailure = -1,
68  CoTokenError = -6,
70  CoOffline = -8,
74 };
75 
81 - (id)initWithToken:(NSString *)token myDeviceId:(NSString *)myDeviceId;
82 
86 - (void)deinit;
87 
95 - (CoError)sendMsg:(NSString *)msg toOtherDeviceId:(NSString *)otherDeviceId;
96 
103 - (CoError)connectToOtherDeviceId:(NSString *)otherDeviceId;
104 
109 - (BOOL)isConnected;
110 
116 - (BOOL)isConnectedViaConnectionType:(CoConnectionType)connectionType;
117 
124 - (CoError)sendVideoH264Frame:(NSData *)h264Frame;
125 
132 - (CoError)sendVideoH264DataChunk:(NSData *)h264DataChunk;
133 
140 - (CoError)sendAudioFrames:(NSData *)audioFrames;
141 
148 - (CoError)sendOtherData:(NSData *)data;
149 
153 - (void)disconnect;
154 
160 - (void)registerPushNotificationsFromDevice:(NSString *)otherDeviceId myDeviceToken:(NSString *)myDeviceToken;
161 
170 - (CoError)sendPushNotificationMsg:(NSString *)msg action:(NSString *)action;
171 
172 @property (nonatomic, weak) id<CjConnectivityDelegate> delegate;
173 
174 @end
175 
176 @protocol CjConnectivityDelegate <NSObject>
177 
178 @required
179 
185 - (void)msgReceived:(NSString *)msg otherDeviceId:(NSString *)otherDeviceId;
186 
194 - (void)connectionEventReceived:(CoConnectionEvent)connectionEvent otherDeviceId:(NSString *)otherDeviceId connectionType:(CoConnectionType)connectionType;
195 
203 - (void)dataReceived:(NSData *)data dataType:(CoDataType)dataType otherDeviceId:(NSString *)otherDeviceId connectionType:(CoConnectionType)connectionType;
204 
205 @end
206 
207 
208 NS_ASSUME_NONNULL_END
Encompasses all connection types (such as for example when receiving and overall timeout event).
Definition: CjConnectivityInterface.h:55
It took too long to attempt the connection. Perhaps the other device is not connected to the network.
Definition: CjConnectivityInterface.h:32
Already attempted the maximum number of connections allowed.
Definition: CjConnectivityInterface.h:33
Network conditions are not good enough for current bitrate. Reduce the video resolution/bitrate when ...
Definition: CjConnectivityInterface.h:22
CoConnectionEvent
CoConnectionEvent gives information about events occurring with a specific connection.
Definition: CjConnectivityInterface.h:20
No associated connection type.
Definition: CjConnectivityInterface.h:51
Peer-to-peer connection over the public internet.
Definition: CjConnectivityInterface.h:53
CoConnectionType
The CoConnectionType indicates what kind of connection we are dealing with (direct local connection,...
Definition: CjConnectivityInterface.h:50
Something is wrong with the token provided.
Definition: CjConnectivityInterface.h:30
Connection via relay server.
Definition: CjConnectivityInterface.h:54
Received a connection request and started initiating connection.
Definition: CjConnectivityInterface.h:27
Already attempted the maximum number of connections allowed.
Definition: CjConnectivityInterface.h:72
Attempted to reconnect more quickly than minimum interval tied to this token. Contact support@seajei....
Definition: CjConnectivityInterface.h:73
Got disconnected because of a network change (such as network lost for example).
Definition: CjConnectivityInterface.h:24
An input parameter is bad.
Definition: CjConnectivityInterface.h:64
CoError
Most methods will return an CoError code. The code indicates success or what type of failure happened...
Definition: CjConnectivityInterface.h:61
Peer sent disconnection request.
Definition: CjConnectivityInterface.h:26
Trying to call functions that need initialization first.
Definition: CjConnectivityInterface.h:66
BOOL isConnected()
Check if we have a data connection with the other device.
An internal error has occurred.
Definition: CjConnectivityInterface.h:65
void deinit()
Disconnects from other device if needed and deinitializes library.
There was an error with the token.
Definition: CjConnectivityInterface.h:68
The network connection is offline.
Definition: CjConnectivityInterface.h:70
Trying to initialize but we are already initialized.
Definition: CjConnectivityInterface.h:67
The token provided is expired.
Definition: CjConnectivityInterface.h:31
Other device's version is too old and not compatible with this device.
Definition: CjConnectivityInterface.h:35
Connection was successful. Gets received when first of 3 possible connection types gets established.
Definition: CjConnectivityInterface.h:29
Device is ready to receive messages to its unique ID.
Definition: CjConnectivityInterface.h:23
Connection was successful on one of the other two of three connection types (CoConnectionType)....
Definition: CjConnectivityInterface.h:28
The token used has a session maximum time limit and that limit has been reached. Contact support@seaj...
Definition: CjConnectivityInterface.h:36
Success return value. No error occurred.
Definition: CjConnectivityInterface.h:62
A generic error. Not enough information for a specific error code.
Definition: CjConnectivityInterface.h:63
Network conditions are good enough for a higher bitrate than the one currently used....
Definition: CjConnectivityInterface.h:21
Definition: CjConnectivityInterface.h:176
Peer stopped responding, indicating that peer either crashed or lost its network connection.
Definition: CjConnectivityInterface.h:25
void disconnect()
Disconnects from other device.
Token status is expired.
Definition: CjConnectivityInterface.h:69
This device's version is too old and not compatible with other device.
Definition: CjConnectivityInterface.h:34
Connection over same local network.
Definition: CjConnectivityInterface.h:52
The data connection is disconnected.
Definition: CjConnectivityInterface.h:71
Definition: CjConnectivityInterface.h:15