pnwebrtc/src/main/java/me/kevingleason/pnwebrtc/PnPeerConnectionClient.java
boolean connect(String userId) {
        if (!peers.containsKey(userId)) { // Prevents duplicate dials.
            if (peers.size() < MAX_CONNECTIONS) {
                PnPeer peer = addPeer(userId);
                peer.pc.addStream(this.localMediaStream);
                try {
                    actionMap.get(CreateOfferAction.TRIGGER).execute(userId, new JSONObject());
                } catch (JSONException e){
                    e.printStackTrace();
                    return false;
                }
                return true;
            }
        }
        this.mRtcListener.onDebug(new PnRTCMessage("CONNECT FAILED. Duplicate dial or max peer " +
                "connections exceeded. Max: " + MAX_CONNECTIONS + " Current: " + this.peers.size()));
        return false;
    }
boolean connect(String userId) {
        if (!peers.containsKey(userId)) { // Prevents duplicate dials.
            if (peers.size() < MAX_CONNECTIONS) {
                PnPeer peer = addPeer(userId);
                peer.pc.addStream(this.localMediaStream);
                try {
                    actionMap.get(CreateOfferAction.TRIGGER).execute(userId, new JSONObject());
                } catch (JSONException e){
                    e.printStackTrace();
                    return false;
                }
                return true;
            }
        }
        this.mRtcListener.onDebug(new PnRTCMessage("CONNECT FAILED. Duplicate dial or max peer " +
                "connections exceeded. Max: " + MAX_CONNECTIONS + " Current: " + this.peers.size()));
        return false;
    }
boolean connect ( String userId ) { if ( ! peers . containsKey ( userId ) ) { // Prevents duplicate dials. if ( peers . size ( ) < MAX_CONNECTIONS ) { PnPeer peer = addPeer ( userId ) ; peer . pc . addStream ( this . localMediaStream ) ; try { actionMap . get ( CreateOfferAction . TRIGGER ) . execute ( userId , new JSONObject ( ) ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; return false ; } return true ; } } this . mRtcListener . onDebug ( new PnRTCMessage ( "CONNECT FAILED. Duplicate dial or max peer " + "connections exceeded. Max: " + MAX_CONNECTIONS + " Current: " + this . peers . size ( ) ) ) ; return false ; }
TODO: Add a max user threshold.
Connect with another user by their ID.
@param userId The user to establish a WebRTC connection with
@return boolean value of success
TODO : Add a max user threshold . Connect with another user by their ID .