언어 설정

Menu
Sites
Language
I can't use socket in TAU Basic template.

I was using socket in basicUI template.

But after I move my code basicUI to TAU Basic template, socket is not work.

Tizen studio gave me an error message: 'app.js (1) :ReferenceError: Can't find variable: io'

and my code is just: 'var socket = io('http://192.198....');'

I use same js, html code and previlege.

Is there anything I forgot? 

Responses

10 댓글
Marco Buettner

did you bind the io-framework correct? Post your index.html

승민 백

<!DOCTYPE html>
<html>
<head>
    <meta name="viewport" content="width=device-width,user-scalable=no">
    <title>Circular UI</title>
    <link rel="stylesheet" href="lib/tau/wearable/theme/default/tau.min.css">
    <link rel="stylesheet" media="all and (-tizen-geometric-shape: circle)" href="lib/tau/wearable/theme/default/tau.circle.min.css">
    <!-- load theme file for your application -->
    <link rel="stylesheet" href="css/style.css">
</head>
<body>
    <div class=contents>
          <div style='margin:auto;'>
              <img src="img/device0.png" id="device"/>
          </div>
     </div>
    <script type="text/javascript" src="lib/tau/wearable/js/tau.min.js"></script>
    <script src="app.js"></script>
    <script src="lowBatteryCheck.js"></script>
    <script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
    <script src="http://code.jquery.com/jquery-1.11.1.js"></script>
</body>
</html>

 

It's my index.html.

Is it something wrong..?

Marco Buettner

Looks perfect and your config.xml?

Iqbal Hossain

Load your app.js after loading the socket and other library. 

change to 

<script src="https://cdn.socket.io/socket.io-1.2.0.js"></script>
<script src="http://code.jquery.com/jquery-1.11.1.js"></script>
<script src="app.js"></script>
<script src="lowBatteryCheck.js"></script>

 

Iqbal Hossain

Also add this privilege if not working

<tizen:privilege name="http://tizen.org/privilege/internet"/>

 

승민 백

Thank you for your replies : )

And this is my config.xml:

 

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://yourdomain/OCUreboot" version="1.0.0" viewmodes="maximized">
    <tizen:application id="XfdRxwsMqt.OCUreboot" package="XfdRxwsMqt" required_version="2.3.2"/>
    <content src="index.html"/>
    <feature name="http://tizen.org/feature/screen.size.normal"/>
    <icon src="icon.png"/>
    <name>OCUreboot</name>
    <tizen:privilege name="http://tizen.org/privilege/healthinfo"/>
    <tizen:privilege name="http://tizen.org/privilege/internet"/>
    <tizen:privilege name="http://tizen.org/privilege/application.launch"/>
    <tizen:profile name="wearable"/>
    <tizen:setting hwkey-event="enable"/>
</widget>

 

I don't understand why this same code, same privileges are work diffrently in basic template and tau template.

I'm crying all night these days.

Marco Buettner

You have to define the network access urls ... try this config.

<?xml version="1.0" encoding="UTF-8"?>
<widget xmlns="http://www.w3.org/ns/widgets" xmlns:tizen="http://tizen.org/ns/widgets" id="http://yourdomain/OCUreboot" version="1.0.0" viewmodes="maximized">
    <tizen:application id="XfdRxwsMqt.OCUreboot" package="XfdRxwsMqt" required_version="2.3.2"/>
    <content src="index.html"/>
    <access origin="https://cdn.socket.io" subdomains="true"/>
    <access origin="http://code.jquery.com" subdomains="true"/>
    <feature name="http://tizen.org/feature/screen.size.normal"/>
    <icon src="icon.png"/>
    <name>OCUreboot</name>
    <tizen:privilege name="http://tizen.org/privilege/healthinfo"/>
    <tizen:privilege name="http://tizen.org/privilege/internet"/>
    <tizen:privilege name="http://tizen.org/privilege/application.launch"/>
    <tizen:profile name="wearable"/>
    <tizen:setting hwkey-event="enable"/>
</widget>

 

승민 백

After I saw your reply, I tried what you said.

But not solved...

Even I inserted script code in variety position but still...

GEUNSOO KIM

it could be the global variable is not ready yet.

If you created app.js with just plain code 'var socket = io('http://192.198....');',  try to put that code into a function and assign it to window.onload like this..

function init()
{
    var socket = io('http://192.198....');
}

window.onload = init();

 

승민 백

Thanks a lot for replies.

I solved the problem. I just inserted this code in my config.xml.

 

<access origin="*" subdomains="true" />

 

This code makes it possible to access external java script code.