$.JsonRpcClient = function(options) {
var self = this;
this.options = $.extend({
- ajaxUrl : null,
- socketUrl : null, ///< The ws-url for default getSocket.
- onmessage : null, ///< Other onmessage-handler.
- login : null, /// auth login
- passwd : null, /// auth passwd
- sessid : null,
- loginParams : null,
- getSocket : function(onmessage_cb) { return self._getSocket(onmessage_cb); }
+ ajaxUrl : null,
+ socketUrl : null, ///< The ws-url for default getSocket.
+ onmessage : null, ///< Other onmessage-handler.
+ login : null, /// auth login
+ passwd : null, /// auth passwd
+ sessid : null,
+ loginParams : null,
+ userVariables : null,
+ getSocket : function(onmessage_cb) { return self._getSocket(onmessage_cb); }
}, options);
self.ws_cnt = 0;
self.options.login = params.login;
self.options.passwd = params.passwd;
self.options.loginParams = params.loginParams;
+ self.options.userVariables = params.userVariables;
};
$.JsonRpcClient.prototype.connectSocket = function(onmessage_cb) {
if (!self.authing && response.error.code == -32000 && self.options.login && self.options.passwd) {
self.authing = true;
- this.call("login", { login: self.options.login, passwd: self.options.passwd, loginParams: self.options.loginParams},
+ this.call("login", { login: self.options.login, passwd: self.options.passwd, loginParams: self.options.loginParams,
+ userVariables: self.options.userVariables},
this._ws_callbacks[response.id].request_obj.method == "login" ?
function(e) {
self.authing = false;
switch_bool_t r = SWITCH_FALSE;
const char *passwd = NULL;
const char *login = NULL;
- cJSON *login_params = NULL;
+ cJSON *json_ptr = NULL;
if (!params) {
*code = CODE_AUTH_FAILED;
switch_event_create(&req_params, SWITCH_EVENT_REQUEST_PARAMS);
switch_assert(req_params);
- if ((login_params = cJSON_GetObjectItem(params, "loginParams"))) {
+ if ((json_ptr = cJSON_GetObjectItem(params, "loginParams"))) {
cJSON * i;
-
- for(i = login_params->child; i; i = i->next) {
+
+ for(i = json_ptr->child; i; i = i->next) {
if (i->type == cJSON_True) {
switch_event_add_header_string(req_params, SWITCH_STACK_BOTTOM, i->string, "true");
} else if (i->type == cJSON_False) {
}
}
+
+ if ((json_ptr = cJSON_GetObjectItem(params, "userVariables"))) {
+ cJSON * i;
+
+ for(i = json_ptr->child; i; i = i->next) {
+ if (i->type == cJSON_True) {
+ switch_event_add_header_string(jsock->user_vars, SWITCH_STACK_BOTTOM, i->string, "true");
+ } else if (i->type == cJSON_False) {
+ switch_event_add_header_string(jsock->user_vars, SWITCH_STACK_BOTTOM, i->string, "false");
+ } else if (!zstr(i->string) && !zstr(i->valuestring)) {
+ switch_event_add_header_string(jsock->user_vars, SWITCH_STACK_BOTTOM, i->string, i->valuestring);
+ }
+ }
+ }
+
switch_event_add_header_string(req_params, SWITCH_STACK_BOTTOM, "action", "jsonrpc-authenticate");
if (switch_xml_locate_user_merged("id", id, domain, NULL, &x_user, req_params) != SWITCH_STATUS_SUCCESS && !jsock->profile->blind_reg) {
switch_event_create(&jsock->params, SWITCH_EVENT_CHANNEL_DATA);
switch_event_create(&jsock->vars, SWITCH_EVENT_CHANNEL_DATA);
+ switch_event_create(&jsock->user_vars, SWITCH_EVENT_CHANNEL_DATA);
add_jsock(jsock);
switch_event_destroy(&jsock->params);
switch_event_destroy(&jsock->vars);
+ switch_event_destroy(&jsock->user_vars);
if (jsock->client_socket > -1) {
close_socket(&jsock->client_socket);
cJSON *msg = NULL;
const char *var = NULL;
switch_caller_profile_t *caller_profile = switch_channel_get_caller_profile(tech_pvt->channel);
+ switch_event_header_t *hp;
- DUMP_EVENT(jsock->params);
+ //DUMP_EVENT(jsock->params);
switch_channel_set_variable(tech_pvt->channel, "verto_user", jsock->uid);
switch_channel_set_variable(tech_pvt->channel, "presence_id", jsock->uid);
switch_channel_set_variable(tech_pvt->channel, "chat_proto", VERTO_CHAT_PROTO);
switch_channel_set_variable(tech_pvt->channel, "verto_host", jsock->domain);
+ for (hp = jsock->user_vars->headers; hp; hp = hp->next) {
+ switch_channel_set_variable(tech_pvt->channel, hp->name, hp->value);
+ }
+
if ((var = switch_event_get_header(jsock->params, "caller-id-name"))) {
caller_profile->callee_id_name = switch_core_strdup(caller_profile->pool, var);
}
char name[512];
const char *var, *destination_number, *call_id = NULL, *sdp = NULL, *bandwidth = NULL,
*caller_id_name = NULL, *caller_id_number = NULL, *remote_caller_id_name = NULL, *remote_caller_id_number = NULL,*context = NULL;
+ switch_event_header_t *hp;
*response = obj;
}
+
+ for (hp = jsock->user_vars->headers; hp; hp = hp->next) {
+ switch_channel_set_variable(channel, hp->name, hp->value);
+ }
+
+
switch_channel_set_profile_var(channel, "callee_id_name", remote_caller_id_name);
switch_channel_set_profile_var(channel, "callee_id_number", remote_caller_id_number);