// This JavaScript was automatically generated by
// Jayrock.JsonRpc.Web.JsonRpcProxyGenerator, Jayrock, Version=0.9.8316.0, Culture=neutral, PublicKeyToken=null
// on viernes, 13 de marzo de 2009 at 9:14:41 (Hora estándar romance)

// Proxy version 1.0

function JsonCore(url)
{
    this["GetUserInfo"] = function(callerId, userId, callback)
    {
        return call("GetUserInfo", [ callerId, userId ], callback);
    }
    
    this["GetUserInfoList"] = function(callerId, userType, callback)
    {
        return call("GetUserInfoList", [ callerId, userType ], callback);
    }
    
    this["ChangeUserStatus"] = function(callerId, userId, statusId, callback)
    {
        return call("ChangeUserStatus", [ callerId, userId, statusId ], callback);
    }
    
    this["InsertConversationMessage"] = function(callerId, convId, sender, receiver, evt, callback)
    {
        return call("InsertConversationMessage", [ callerId, convId, sender, receiver, evt ], callback);
    }
    
    this["SendRemoteControlInvitation"] = function(callerId, conv, user, callback)
    {
        return call("SendRemoteControlInvitation", [ callerId, conv, user ], callback);
    }
    
    this["SendRemoteControlAcceptAnswer"] = function(callerId, conv, user, answer, callback)
    {
        return call("SendRemoteControlAcceptAnswer", [ callerId, conv, user, answer ], callback);
    }
    
    this["SendPing"] = function(callerId, conv, user, callback)
    {
        return call("SendPing", [ callerId, conv, user ], callback);
    }
    
    this["SendPingReply"] = function(callerId, conv, user, answer, callback)
    {
        return call("SendPingReply", [ callerId, conv, user, answer ], callback);
    }
    
    this["SendRemoteControlRejectAnswer"] = function(callerId, conv, user, answer, callback)
    {
        return call("SendRemoteControlRejectAnswer", [ callerId, conv, user, answer ], callback);
    }
    
    this["CreateConversation"] = function(callerId, userId, callback)
    {
        return call("CreateConversation", [ callerId, userId ], callback);
    }
    
    this["SendFileUploadedNotification"] = function(callerId, conv, user, answer, callback)
    {
        return call("SendFileUploadedNotification", [ callerId, conv, user, answer ], callback);
    }
    
    this["CloseConversation"] = function(callerId, conv, callback)
    {
        return call("CloseConversation", [ callerId, conv ], callback);
    }
    
    this["JoinConversation"] = function(callerId, conv, user, callback)
    {
        return call("JoinConversation", [ callerId, conv, user ], callback);
    }
    
    this["LeaveConversation"] = function(callerId, conv, user, callback)
    {
        return call("LeaveConversation", [ callerId, conv, user ], callback);
    }
    
    this["GetConversationInfo"] = function(callerId, conv, callback)
    {
        return call("GetConversationInfo", [ callerId, conv ], callback);
    }
    
    this["GetConversationEvents"] = function(callerId, conv, LastEventIndex, callback)
    {
        return call("GetConversationEvents", [ callerId, conv, LastEventIndex ], callback);
    }
    
    this["GetConversationUsers"] = function(callerId, conv, callback)
    {
        return call("GetConversationUsers", [ callerId, conv ], callback);
    }
    
    this["LogOnAdminUser"] = function(userName, password, lang, callback)
    {
        return call("LogOnAdminUser", [ userName, password, lang ], callback);
    }
    
    this["LogOnSiteUser"] = function(userName, password, lang, callback)
    {
        return call("LogOnSiteUser", [ userName, password, lang ], callback);
    }
    
    this["LogOnOperatorUser"] = function(userName, password, lang, callback)
    {
        return call("LogOnOperatorUser", [ userName, password, lang ], callback);
    }
    
    this["LogOnOperatorUserV2"] = function(userName, password, lang, callback)
    {
        return call("LogOnOperatorUserV2", [ userName, password, lang ], callback);
    }
    
    this["LogOnEndUser"] = function(licenseCode, machineCode, lang, callback)
    {
        return call("LogOnEndUser", [ licenseCode, machineCode, lang ], callback);
    }
    
    this["LogOff"] = function(callerId, userid, callback)
    {
        return call("LogOff", [ callerId, userid ], callback);
    }
    
    this["GetFilteredOperatorList"] = function(callerId, convId, callback)
    {
        return call("GetFilteredOperatorList", [ callerId, convId ], callback);
    }
    
    this["GetUnassignedConversationList"] = function(callerId, callback)
    {
        return call("GetUnassignedConversationList", [ callerId ], callback);
    }
    
    this["TransferConversation"] = function(callerId, conv, newUserId, oldUseId, callback)
    {
        return call("TransferConversation", [ callerId, conv, newUserId, oldUseId ], callback);
    }
    
    this["CreateJoinConversation"] = function(callerId, sUserId1, sUserId2, callback)
    {
        return call("CreateJoinConversation", [ callerId, sUserId1, sUserId2 ], callback);
    }
    
    this["GetLastSurveys"] = function(callerId, oldUseId, callback)
    {
        return call("GetLastSurveys", [ callerId, oldUseId ], callback);
    }
    
    this["GetUserConversationInfoList"] = function(callerId, sUserId, callback)
    {

        return call("GetUserConversationInfoList", [ callerId, sUserId ], callback);
    }
    
    this["GetUserFinalizedConversationInfoList"] = function(callerId, sUserId, callback)
    {
        return call("GetUserFinalizedConversationInfoList", [ callerId, sUserId ], callback);
    }
    
    this["GetConversationFrequentAnswerList"] = function(callerId, sConvId, callback)
    {
        return call("GetConversationFrequentAnswerList", [ callerId, sConvId ], callback);
    }
    
    this["GetWaitingMessage"] = function(callerId, userId, callback)
    {
        return call("GetWaitingMessage", [ callerId, userId ], callback);
    }
    
    this["CreateConversationWithSkills"] = function(callerId, userId, skills, callback)
    {
        return call("CreateConversationWithSkills", [ callerId, userId, skills], callback);
    }
    
    this["Logger"] = function(exceptionMessage, callback)
    {
        return call("Logger", [ exceptionMessage ], callback);
    }
    
    this["MakePseudoVipUser"] = function(callerId, license, callback)
    {
        return call("MakePseudoVipUser", [ callerId, license], callback);
    }
    
    /* Returns an array of method names implemented by this service. */
    
    this["system.listMethods"] = function(callback)
    {
        return call("system.listMethods", [ ], callback);
    }
    
    /* Returns the version server implementation using the major, minor, build and revision format. */
    
    this["system.version"] = function(callback)
    {
        return call("system.version", [ ], callback);
    }
    
    /* Returns a summary about the server implementation for display purposes. */
    
    this["system.about"] = function(callback)
    {
        return call("system.about", [ ], callback);
    }
    
    var url = (typeof(url) == 'string') ? url : '../../App_Handler/JsonCore.ashx';
    var self = this;
    var nextId = 0;

    function call(method, params, callback)
    {
        var request = { id : nextId++, method : method, params : params };
        return callback == null ? 
            callSync(method, request) : callAsync(method, request, callback);
    }

    function callSync(method, request)
    {
        var http = newHTTP();
        http.open('POST', url, false, self.httpUserName, self.httpPassword);
        setupHeaders(http, method);
        http.send(JSON.stringify(request));
        if (http.status != 200)
            throw { message : http.status + ' ' + http.statusText, toString : function() { return message; } };
        var response = JSON.eval(http.responseText);
        if (response.error != null) throw response.error;
        return response.result;
    }

    function callAsync(method, request, callback)
    {
        var http = newHTTP();
        http.open('POST', url, true, self.httpUserName, self.httpPassword);
        setupHeaders(http, method);

        http.onreadystatechange = function() { http_onreadystatechange(http, callback, request.params); }
        http.send(JSON.stringify(request));
        return request.id;
    }

    function setupHeaders(http, method)
    {
        http.setRequestHeader('Content-Type', 'text/plain; charset=utf-8');
        http.setRequestHeader('X-JSON-RPC', method);
    }

    function http_onreadystatechange(sender, callback, params)
    {
        if (sender.readyState == /* complete */ 4)
        {
            var response = sender.status == 200 ? JSON.eval(sender.responseText) : {};
            
            response.xmlHTTP = sender;
            response.params = params;
            
            delete sender['onreadystatechange'];
            sender = null;
            
            callback(response);
        }
    }

    function newHTTP()
    {
        if (typeof(window) != 'undefined' && window.XMLHttpRequest)
            return new XMLHttpRequest(); /* IE7, Safari 1.2, Mozilla 1.0/Firefox, and Netscape 7 */
        else
            return new ActiveXObject('Microsoft.XMLHTTP'); /* WSH and IE 5 to IE 6 */
    }
}

JsonCore.rpcMethods = ["GetUserInfo","GetUserInfoList","ChangeUserStatus","InsertConversationMessage","SendRemoteControlInvitation","SendRemoteControlAcceptAnswer","SendRemoteControlRejectAnswer","CreateConversation","SendFileUploadedNotification","CloseConversation","JoinConversation","LeaveConversation","GetConversationInfo","GetConversationEvents","GetConversationUsers","LogOnAdminUser","LogOnSiteUser","LogOnOperatorUser","LogOnOperatorUserV2","LogOnEndUser","LogOff","GetFilteredOperatorList","GetUnassignedConversationList","TransferConversation","CreateJoinConversation","GetLastSurveys","GetUserConversationInfoList","GetUserFinalizedConversationInfoList","GetConversationFrequentAnswerList","GetWaitingMessage","CreateConversationWithSkills","Logger", "system.listMethods","system.version","system.about", "MakePseudoVipUser"];

