A peer class.
More...
#import <SKWPeer.h>
|
(nonnull NSString *) | + sdkVersion |
| Getting current SDK version.
|
|
|
NSString *__nullable | identity |
| The brokering ID of this peer. More...
|
|
NSDictionary *__nullable | connections |
| A object array of all connections this peer, keyed by the remote peer's ID.
|
|
BOOL | isDisconnected |
| false if there is an active connection to the PeerServer.
|
|
BOOL | isDestroyed |
| true if this peer and all of its connections can no longer be used.
|
|
◆ callWithId:stream:
Calls the remote peer specified by id and returns a media connection.
Be sure to listen on the error event in case the connection fails.
- Parameters
-
peerId | Remote peer ID |
stream | Video stream |
- Returns
- Media connection object
◆ callWithId:stream:options:
Calls the remote peer specified by id and returns a media connection.
Be sure to listen on the error event in case the connection fails.
- Parameters
-
peerId | Remote peer ID |
stream | Video stream |
options | Option seeting dictionary |
- Returns
- Media connection object
◆ connectWithId:
Connects to the remote peer specified by id and returns a data connection.
Be sure to listen on the error event in case the connection fails.
- Parameters
-
peerId | The brokering ID of the remote peer (their peer.id). |
- Returns
Data connection object
◆ connectWithId:options:
Connects to the remote peer specified by id and returns a data connection.
Be sure to listen on the error event in case the connection fails.
- Parameters
-
peerId | The brokering ID of the remote peer (their peer.id). |
options | Option setting dictionary |
- Returns
Data connection object
◆ destroy
Close the connection to the server and terminate all existing connections.
peer.destroyed will be set to true.
- Returns
- Processing result
◆ disconnect
Close the connection to the server, leaving all existing data and media connections intact.
peer.disconnected will be set to true and the disconnected event will fire.
- Returns
- Processing result
◆ initWithId:options:
- (instancetype __nullable) initWithId: |
|
(NSString *__nullable) |
peerId |
options: |
|
(SKWPeerOption *__nullable) |
options |
|
|
| |
A peer can connect to other peers and listen for connections.
NSString* curtomPeerId = @"my-peer-id";
options.
key =
@"{your-dev-key}";
options.
domain = @”{your-domain}”;
options.
debug = SKW_PEER_DEBUG_LEVEL_ALL_LOGS;
SKWPeer* peer = [[
SKWPeer alloc] initWithId:curtomPeerId options:options];
- Parameters
-
peerId | Other peers can connect to this peer using the provided ID. If no ID is given, one will be generated by the brokering server. |
options | Option seetings. |
- Returns
- PeerObjC object
◆ initWithOptions:
- (instancetype __nullable) initWithOptions: |
|
(SKWPeerOption *__nullable) |
options |
|
A peer can connect to other peers and listen for connections.
ID is retrieve from brokering server.
options.
key =
@"{your-dev-key}";
options.
domain = @”{your-domain}”;
options.
debug = SKW_PEER_DEBUG_LEVEL_ALL_LOGS;
- Parameters
-
- Returns
- PeerObjC object
◆ joinRoomWithName:options:
- (SKWRoom* __nullable) joinRoomWithName: |
|
(NSString *__nonnull) |
roomName |
options: |
|
(SKWRoomOption *__nonnull) |
option |
|
|
| |
Full mesh room example:
NSString* roomName = @"fullmesh_videochat_room";
option.stream = localStream;
SFU room example:
NSString* roomName = @"sfu_textchat_room";
- Parameters
-
roomName | Room name |
option | Room option |
- Returns
- Room object
◆ listAllPeers:
- (void) listAllPeers: |
|
(void(^)(NSArray *__nullable)) |
callback |
|
Listing peer ID.
for (NSString* strPeer in aryPeers) {
}
}];
- Parameters
-
◆ on:callback:
Set blocks for peer events.
(Block Literal Syntax)
[peer
on:SKW_PEER_EVENT_OPEN
callback:^(NSObject* obj) {
if (YES == [obj isKindOfClass:[NSString class]]) {
NSString* ownId = (NSString *)obj;
}
}];
[peer
on:SKW_PEER_EVENT_CONNECTION
callback:^(NSObject* obj) {
}];
[peer
on:SKW_PEER_EVENT_CALL
callback:^(NSObject* obj) {
}];
[peer
on:SKW_PEER_EVENT_CLOSE
callback:^(NSObject* obj) {
}];
[peer
on:SKW_PEER_EVENT_DISCONNECTED
callback:^(NSObject* obj) {
}];
[peer
on:SKW_PEER_EVENT_ERROR
callback:^(NSObject* obj) {
NSLog(@"%@", err);
}];
- Parameters
-
event | Event type |
callback | Callback block literal |
◆ reconnect
Attempt to reconnect to the server with the peer's old ID.
◆ updateCredential:
credential.
timestamp = [[NSDate date] timeIntervalSince1970];
credential.
authToken =
@"calculated auth token";
- Parameters
-
newCredential | new credential |
◆ identity
- (NSString* __nullable) identity |
|
readnonatomicassign |
The brokering ID of this peer.
If no ID was specified in the constructor, this will be undefined until the open event is emitted.
NSUInteger ttl
Time to live; The credential expires at timestamp + ttl.
Definition: SKWPeerCredential.h:24
SKWMediaConnection *__nullable callWithId:stream:options:(NSString *__nonnull peerId,[stream] SKWMediaStream *__nullable stream,[options] SKWCallOption *__nullable options)
Calls the remote peer specified by id and returns a media connection.
Alternative class as DataConnection.
Definition: SKWDataConnection.h:41
BOOL destroy()
Close the connection to the server and terminate all existing connections.
void on:callback:(SKWPeerEventEnum event,[callback] SKWPeerEventCallback __nullable callback)
Set blocks for peer events.
Error information class.
Definition: SKWPeerError.h:55
NSString *__nullable key
API key for the cloud PeerServer.
Definition: SKWPeerOption.h:63
A peer class.
Definition: SKWPeer.h:98
Media stream.
Definition: SKWMediaStream.h:18
void reconnect()
Attempt to reconnect to the server with the peer's old ID.
The credential used to authenticate peer.
Definition: SKWPeerCredential.h:14
SKWDataConnection *__nullable connectWithId:(NSString *__nonnull peerId)
Connects to the remote peer specified by id and returns a data connection.
Alternative class as MediaConnection.
Definition: SKWMediaConnection.h:52
NSString *__nullable domain
Domain related to the SkyWay API Key.
Definition: SKWPeerOption.h:98
NSUInteger timestamp
Current UNIX timestamp.
Definition: SKWPeerCredential.h:19
@ SKW_ROOM_MODE_MESH
Fullmesh type room.
Definition: SKWRoomOption.h:21
NSString *__nullable metadata
Any type of metadata associated with the connection, passed in by whoever initiated the connection.
Definition: SKWCallOption.h:23
SKWDebugLevelEnum debug
Prints log messages depending on the debug level passed in.
Definition: SKWPeerOption.h:93
NSString *__nullable label
Label to easily identify the connection on either peer.
Definition: SKWConnectOption.h:19
BOOL turn
Using SkyWay TURN server.
Definition: SKWPeerOption.h:103
BOOL disconnect()
Close the connection to the server, leaving all existing data and media connections intact.
SKWDataConnection *__nullable connectWithId:options:(NSString *__nonnull peerId,[options] SKWConnectOption *__nullable options)
Connects to the remote peer specified by id and returns a data connection.
SKWPeer connect options.
Definition: SKWConnectOption.h:14
NSString * authToken
Credential token calculated with HMAC.
Definition: SKWPeerCredential.h:29
@ SKW_ROOM_MODE_SFU
SFU type room.
Definition: SKWRoomOption.h:25
SKWMediaConnection *__nullable callWithId:stream:(NSString *__nonnull peerId,[stream] SKWMediaStream *__nullable stream)
Calls the remote peer specified by id and returns a media connection.
NSString *__nullable metadata
Any type of metadata associated with the connection, passed in by whoever initiated the connection.
Definition: SKWConnectOption.h:27
SFU room class.
Definition: SKWSFURoom.h:24
SKWPeer call options.
Definition: SKWCallOption.h:14
SKWPeer initialize option class.
Definition: SKWPeerOption.h:53
void listAllPeers:(void(^ __nullable callback)(NSArray *__nullable))
Listing peer ID.
SKWRoomModeEnum mode
Room Mode.
Definition: SKWRoomOption.h:36
void updateCredential:(SKWPeerCredential *__nonnull newCredential)
Mesh room class.
Definition: SKWMeshRoom.h:22
Room Options.
Definition: SKWRoomOption.h:31
SKWSerializationEnum serialization
The serialization format of the data sent over the connection.
Definition: SKWConnectOption.h:32
@ SKW_SERIALIZATION_NONE
NONE.
Definition: SKWConnection.h:26