0

I am using a javascript client with SignalR 2.0.3. I have server side function in hub that returns me list of free users. From that results I call one user and want to return true from CallaType function. But done function runs in separate thread and CallaType execute separately.. It is not even possible

available_users = chat.server.getAvailableUsers(type, callnotattendingusers.list);

CallaType: function (type, containerdiv) {
    var Isresult = false;
    var available_users = new Array();
    var chat = $.connection.lPServer;

    chat.server.getAvailableUsers(type, callnotattendingusers.list).done(function (users) {
        available_users = users;

        if (available_users.length > 0) {
            var tryusername = available_users[0].Name;

            btn = $('#' + containerdiv + ' input[value="Call ' + tryusername + '"]')
            if (btn) {
                waitbox.show_connecting(containerdiv);
                btn.click();
                Isresult = true;
                return true;
            }
        }
        else {
            Isresult = false;
            return false;
        }
    });
    return Isresult;
},
Waleed Iqbal
  • 1,308
  • 19
  • 35
Dure Sameen
  • 133
  • 1
  • 11
  • possible duplicate of [How to return the response from an AJAX call?](http://stackoverflow.com/questions/14220321/how-to-return-the-response-from-an-ajax-call) – Lars Höppner Apr 24 '14 at 19:54
  • No SignalR server side methods are different than normal AJAX call.. – Dure Sameen Apr 25 '14 at 06:52
  • it's the same problem - you have asynchronous code (in both cases, you're using a promise) and want to return its result - just read the answer I linked – Lars Höppner Apr 25 '14 at 07:38

0 Answers0