1

session

Тема: session

good day, i have an app using wialon  and i would like to know how i can make a search by name and no by id, example:

function init() { 
    var sess = wialon.core.Session.getInstance(); 
    // specify what kind of data should be returned
    var flags = wialon.item.Item.dataFlag.base | wialon.item.Unit.dataFlag.lastMessage;

    sess.loadLibrary("itemIcon"); 
    sess.updateDataFlags( 
        [{type: "type", data: "avl_unit", flags: flags,mode: 0}], 
        function (code) { 
            if (code) { msg(wialon.core.Errors.getErrorText(code)); return; } 
            
            var units = sess.getItems("avl_unit"); 
            var unidad = wialon.core.Session.getInstance().getItem(13422969); 
            var posicion = unidad.getPosition();
             
            if (map) { 
        var icon = L.icon({
            iconUrl: unidad.getIconUrl(32)
        });
        if (!marker) {
            marker = L.marker({lat: posicion.y, lng: posicion.x}, {icon: icon}).addTo(map);
        } else {
           marker.setLatLng({lat: posicion.y, lng: posicion.x});
           marker.setIcon(icon);
        }
        map.setView({lat: posicion.y, lng: posicion.x});
    }
            
            
            alert(unidad.getName());
            if (!units || !units.length){ msg("No units found"); return; } 
           
          
    });
}

next line, find car by id

var unidad = wialon.core.Session.getInstance().getItem(13422969); 

i wanna use search by name

var unidad = wialon.core.Session.getInstance().getName(name-car); 

is possible do this? thanks for your help

2

session

(16/11/2016 19:40:36 отредактировано prabhu.janakiraman)

Re: session

Hi friends

Please answer for the below questions

1. What is the default time out for SID?
2. How to maintain the session? Is there any concept of refresh token?
3. How to check the Company Name - Uniqueness using a mid level user token
Check the below list. If i am using level 2 user's token and in that if i try to check the company name in search i wont be getting the level 1 user's company name. so in those cases how do i check the company uniqueness.

Level 1 user
Level 2 User
Level 3 User
Level 4 User

Thanks
J Prabhu
3

session

(24/11/2016 11:28:27 отредактировано deal)

Re: session

israelpalmeros, there is no opportunity to search units in session by some of it's field.
But You can achieve this like this:

var unitName = "some_name";
var unit = null;
var units = wialon.core.Session.getInstance().getItems("avl_unit");
for (var i = 0; i < units.length; i++) {
    if (units[i].getName() == unitName) {
        unit = units[i];
        break;
    }
}
if (unit) {
    alert("unit with name " + unitName + " was found");
}

Or if You need some filter by units' name:

var unitName = "Un"; // some part of name from input
var unitsFound = [];
var units = wialon.core.Session.getInstance().getItems("avl_unit");
for (var i = 0; i < units.length; i++) {
    if (units[i].getName().indexOf(unitName) >= 0) {
        unitsFound.push(units[i]);
    }
}
if (unitsFound.length) {
    alert(units.length + " units containing " + unitName + " in name were found");
}
Head of Wialon Local Department
Gurtam
4

session

Re: session

prabhu.janakiraman, here are the answers on Your questions:
1. Wialon session will expire after 5 min of inactivity (no requests).
2. To keep session alive just execute some lightweight requests every few minutes or seconds (for example /avl_evts).
As for token refreshment - You can create token with unlimited duration (using 0 as value) and then resulting token will expire only after 100 days of inactivity.
3. Give us more details about Your request for getting company name.

Head of Wialon Local Department
Gurtam