pnwebrtc/src/main/java/me/kevingleason/pnwebrtc/PnPeerConnectionClient.java
public static JSONObject generateUserMessage(String userId, JSONObject message){
        JSONObject json = new JSONObject();
        try {
            JSONObject packet = new JSONObject();
            packet.put(PnRTCMessage.JSON_USERMSG, message);
            json.put(PnRTCMessage.JSON_PACKET, packet);
            json.put(PnRTCMessage.JSON_ID, ""); //Todo: session id, unused in js SDK?
            json.put(PnRTCMessage.JSON_NUMBER, userId);
        } catch (JSONException e){
            e.printStackTrace();
        }
        return json;
    }
public static JSONObject generateUserMessage(String userId, JSONObject message){
        JSONObject json = new JSONObject();
        try {
            JSONObject packet = new JSONObject();
            packet.put(PnRTCMessage.JSON_USERMSG, message);
            json.put(PnRTCMessage.JSON_PACKET, packet);
            json.put(PnRTCMessage.JSON_ID, ""); //Todo: session id, unused in js SDK?
            json.put(PnRTCMessage.JSON_NUMBER, userId);
        } catch (JSONException e){
            e.printStackTrace();
        }
        return json;
    }
public static JSONObject generateUserMessage ( String userId , JSONObject message ) { JSONObject json = new JSONObject ( ) ; try { JSONObject packet = new JSONObject ( ) ; packet . put ( PnRTCMessage . JSON_USERMSG , message ) ; json . put ( PnRTCMessage . JSON_PACKET , packet ) ; json . put ( PnRTCMessage . JSON_ID , "" ) ; //Todo: session id, unused in js SDK? json . put ( PnRTCMessage . JSON_NUMBER , userId ) ; } catch ( JSONException e ) { e . printStackTrace ( ) ; } return json ; }
Static method to generate the proper JSON for a user message. Use this when you don't have
a {@link me.kevingleason.pnwebrtc.PnRTCClient} instantiated. Simply send a publish with the
returned JSONObject to the ID that a user is subscribed to.
@param userId Your UserID, needed to tag the message
@param message The message you with to send some other user
@return JSONObject properly formatted for the PubNub WebRTC API
Static method to generate the proper JSON for a user message . Use this when you don t have a {