phonertc is not defined - Cordova phonertc on browser

Giosch

I'm trying to build a test app using the phonertc plugin for apache cordova. I'm following the wiki, so i've created the turn server, and i've implemented a socket.io signaling server. All those servers are working.

But when i try build a demo app, after creating the project, adding platforms and the plugin, copying from the wiki,

var config = {
    isInitiator: true,
    turn: {
        host: 'turn:turn.example.com:3478',
        username: 'test',
        password: '123'
    },
    streams: {
        audio: true,
        video: false
    }
}

var session = new phonertc.Session(config);

i get error on

var session = new phonertc.Session(config);

while running the demo on chrome. The error is

main.js:27 Uncaught ReferenceError: phonertc is not defined

The complete version of the index.html is

<!DOCTYPE html>

<html>
    <head>
        <meta name="format-detection" content="telephone=no">
        <meta name="msapplication-tap-highlight" content="no">
        <meta name="viewport" content="user-scalable=no, initial-scale=1, maximum-scale=1, minimum-scale=1, width=device-width">
        <link rel="stylesheet" type="text/css" href="css/index.css">
        <title>Hello World</title>
    </head>
    <body>
        <div class="app">
            <h1>Apache Cordova</h1>
            <div id="deviceready" class="blink">
                <p class="event listening">Connecting to Device</p>
                <p class="event received">Device is Ready</p>
            </div>
        </div>
        <script type="text/javascript" src="cordova.js"></script>
        <script type="text/javascript" src="js/index.js"></script>
        <script src="js/socket.io-1.4.5.js"></script>
        <script src="js/main.js"></script>
        <script>
            document.addEventListener('deviceready', function() {
                doAll();
            });
        </script>
    </body>
</html>

index.js and cordova.js are the dafault from the cordova hello world, main.js is

var socket;
var config;
var session;
function doAll(){
    socket;
    function setup(){
        socket = io.connect("http://192.168.1.121:3000");
        socket.emit("add-user", {"userCode": "1"});

    }
    setup();


    config = {
        isInitiator: true,
        turn: {
            host: 'turn:192.168.1.121:3478',
            username: 'aaaa',
            password: 'bbbb'
        },
        streams: {
            audio: true,
            video: false
        }
    }

    session = new phonertc.Session(config);
    session.on('sendMessage', function (data) { 
        socket.emit("private-message",{content:data,userCode:"2"});
    });
    socket.on("add-message", function(data){

            console.log(data.content);
            session.receiveMessage(JSON.parse(data.content));
        });
    session.on('answer', function () { 
        console.log('Other client answered!');
    });

    session.on('disconnect', function () { 
        console.log('Other client disconnected!');
    });
    session.call();
}

I know, the code is horrible, but it is just a demo. How do i solve the reference to phonertc? Do i need to import something on in the index.html? Thanks

Giosch

Ok, i changed the line

var session = new phonertc.Session(config);

to

var session = new cordova.plugins.phonertc.Session(config);

now it works.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

PhoneRTC demo application

From Dev

Running PhoneRTC Demo

From Dev

PhoneRTC: Send data from Java to Javascript on start

From Dev

How to keep the display awake in a PhoneRTC video call?

From Dev

In PhoneRTC, how can I turn an existing voice chat into a video chat?

From Dev

Cordova: LocalFileSystem is not defined

From Dev

Ionic : LocalFileSystem is not defined in Cordova

From Dev

Browser error: PrimeFacesExt is not defined

From Dev

cordova-plugin-file in Chrome: cordova is not defined

From Dev

Cordova exec function not defined in cordova-2.1.0

From Dev

How to change default browser of cordova browser platform?

From Dev

Cordova: Uncaught ReferenceError: FileTransfer is not defined

From Dev

ngCordova - cordova.plugins not defined

From Dev

hiding the cordova in app browser not working

From Dev

Cordova In-app Browser Limitations

From Dev

What is the browser used by cordova on iOS?

From Dev

Cordova In-app Browser Limitations

From Dev

karma + jasmine, ReferenceError: browser is not defined

From Dev

Where is keys() function defined in the browser?

From Dev

slimScroll is not defined on Browser Back Button

From Dev

How to check if click() is defined for the browser?

From Dev

slimScroll is not defined on Browser Back Button

From Dev

Where is keys() function defined in the browser?

From Dev

Firefox WebExtension APIs "browser is not defined"

From Dev

cordova is not defined - cordova.js has already been loaded :: Ionic

From Dev

Connection is not defined in cordova network information plugin

From Dev

File options is not defined in cordova file transfer

From Dev

Cordova plugin error: "Uncaught module ... already defined"

From Dev

JQuery returning Uncaught Error: cordova already defined

Related Related

  1. 1

    PhoneRTC demo application

  2. 2

    Running PhoneRTC Demo

  3. 3

    PhoneRTC: Send data from Java to Javascript on start

  4. 4

    How to keep the display awake in a PhoneRTC video call?

  5. 5

    In PhoneRTC, how can I turn an existing voice chat into a video chat?

  6. 6

    Cordova: LocalFileSystem is not defined

  7. 7

    Ionic : LocalFileSystem is not defined in Cordova

  8. 8

    Browser error: PrimeFacesExt is not defined

  9. 9

    cordova-plugin-file in Chrome: cordova is not defined

  10. 10

    Cordova exec function not defined in cordova-2.1.0

  11. 11

    How to change default browser of cordova browser platform?

  12. 12

    Cordova: Uncaught ReferenceError: FileTransfer is not defined

  13. 13

    ngCordova - cordova.plugins not defined

  14. 14

    hiding the cordova in app browser not working

  15. 15

    Cordova In-app Browser Limitations

  16. 16

    What is the browser used by cordova on iOS?

  17. 17

    Cordova In-app Browser Limitations

  18. 18

    karma + jasmine, ReferenceError: browser is not defined

  19. 19

    Where is keys() function defined in the browser?

  20. 20

    slimScroll is not defined on Browser Back Button

  21. 21

    How to check if click() is defined for the browser?

  22. 22

    slimScroll is not defined on Browser Back Button

  23. 23

    Where is keys() function defined in the browser?

  24. 24

    Firefox WebExtension APIs "browser is not defined"

  25. 25

    cordova is not defined - cordova.js has already been loaded :: Ionic

  26. 26

    Connection is not defined in cordova network information plugin

  27. 27

    File options is not defined in cordova file transfer

  28. 28

    Cordova plugin error: "Uncaught module ... already defined"

  29. 29

    JQuery returning Uncaught Error: cordova already defined

HotTag

Archive