1

Invalid service when requesting units or user

Topic: Invalid service when requesting units or user

Hi,

I use wialon sdk within backbone+requirejs+jquery mobile mobile application.
Every time I switch to page that has wialon login

wialon.core.Session.getInstance().login(username, password, "", // try to login
                        function (code) { // login callback
                            // if error code - print error message
                            if (code) {
console.log(wialon.core.Errors.getErrorText(code));
                                return;
                            }
                            console.log("Logged successfully");
                         });

I receive error code 2 or Invalid service error.
But when I refresh the switched page I successfully log.

Do you have any idea what could be the reason for this behaviour?

2

Invalid service when requesting units or user

(edited by spev 22/10/2014 15:07:33)

Re: Invalid service when requesting units or user

Hi.
You must initialize the session and check if you are already logged in.
You can find example on Playground

var sess = wialon.core.Session.getInstance();
var user = sess.getCurrUser(); 
if( user ) { // Check state
    console.log("Already logged as '" + user.getName()+"'"); 
} else {
    sess.initSession("https://hst-api.wialon.com"); // initialize Wialon session
    sess.login(username, password, "",
                        function (code) {
                            if (code) {
                                console.log(wialon.core.Errors.getErrorText(code));
                                return;
                            }
                            console.log("Logged successfully");
                         });
}
Telegram: Обновления Wialon, Wialon updates
Google Chrome Extensions: Wialon Units Map | Gurtam Forum Notifications | Wialon Apps Launcher
Evgenij Spitsyn, Developer, flespi team
3

Invalid service when requesting units or user

Re: Invalid service when requesting units or user

Thanks a lot. That was the issue