Skip to content

peerJS port in Objective-C. webRTC client to connect to peerjs-server.

Notifications You must be signed in to change notification settings

satansly/PeerObjC

Repository files navigation

PeerObjectiveC

About

PeerObjC is PeerJS port to iOS. It allows you to setup your client easily and communicate to peerjs-server.

This library inspires from AppRTCDemo (that Google has been published) for peerjs-server signaling process and PeerJS and PeerObjectiveC.

Getting Started

  1. Install via cocoapods

    $ pod 'PeerObjC'
    
  2. Get PeerJS API Key or setup your own server Go to PeerJS Server and create an API key.

  3. Initialize OGPeerOptions and set server details as needed:

    Custom server

    OGPeerOptions * options = [[OGPeerOptions alloc] init];
    options.key = @"peerjs";
    options.host = @"192.198.0.3";
    options.port = @(9000);
    options.path = @"";
    options.secure = NO;
    options.config = [OGPeerConfig defaultConfig];
    options.debugLevel = DDLogLevelDebug;

    PeerJS Cloud

    OGPeerOptions * options = [[OGPeerOptions alloc] init];
    options.key = @"<your api key>";
    options.config = [OGPeerConfig defaultConfig];
    options.debugLevel = DDLogLevelDebug;
  4. Initialize OGPeer with options to create connection

    OGPeer * peer = [[OGPeer alloc] initWithId:@"<your peer id>" options:options];
    [peer addDelegate:self]; //Important for receiving updates from peer
    
  5. Connect to a peer for data/messages exchange

    	OGDataConnectionOptions * options = [[OGDataConnectionOptions alloc] init];
        options.label = @"MyLabel";
        options.serialization = OGSerializationBinary;
        OGDataConnection * conn = [_peer connect:@"<other peer id>" options:options];
  6. Call a peer with Audio/Video call

            OGMediaConnectionOptions* moptions = [[OGMediaConnectionOptions alloc] init];
            moptions.type = OGStreamTypeBoth;
            moptions.direction = AVCaptureDevicePositionFront;
            OGMediaConnection * mconnection = [_peer call:@"<other peer id>" options:moptions];
  7. To receive data and media connections. Implement OGMediaConnectionDelegate and OGDataConnectionDelegate and remember to add the delegate class via addDelegate: method

License

MIT

About

peerJS port in Objective-C. webRTC client to connect to peerjs-server.

Resources

Stars

Watchers

Forks

Packages

No packages published