提交 12a6b8bc authored 作者: Michael Jerris's avatar Michael Jerris

FS-7889: [mod_conference] move conference chat to use an event channel so…

FS-7889: [mod_conference] move conference chat to use an event channel so messages only go to the right 'room' for the conference
上级 c702eda6
......@@ -1436,6 +1436,14 @@
//$(".jsDataTable").width(confMan.params.hasVid ? "900px" : "800px");
verto.subscribe(confMan.params.laData.chatChannel, {
handler: function(v, e) {
if (typeof(confMan.params.chatCallback) === "function") {
confMan.params.chatCallback(v,e);
}
}
});
if (confMan.params.laData.role === "moderator") {
atitle = "Action";
awidth = 600;
......@@ -1588,7 +1596,18 @@
}
});
};
$.verto.confMan.prototype.sendChat = function(message, type) {
var confMan = this;
confMan.verto.rpcClient.call("verto.broadcast", {
"eventChannel": confMan.params.laData.chatChannel,
"data": {
"action": "send",
"message": message,
"type": type
}
});
};
$.verto.confMan.prototype.destroy = function() {
......@@ -1600,6 +1619,10 @@
confMan.lt.destroy();
}
if (confMan.params.laData.chatChannel) {
confMan.verto.unsubscribe(confMan.params.laData.chatChannel);
}
if (confMan.params.laData.modChannel) {
confMan.verto.unsubscribe(confMan.params.laData.modChannel);
}
......
This diff was suppressed by a .gitattributes entry.
......@@ -70,15 +70,11 @@ function setupChat() {
$("#chatwin").html("");
$("#chatsend").click(function() {
if (!cur_call && chatting_with) {
if (!cur_call || !chatting_with || !confMan) {
return;
}
cur_call.message({to: chatting_with,
body: $("#chatmsg").val(),
from_msg_name: cur_call.params.caller_id_name,
from_msg_number: cur_call.params.caller_id_number
});
confMan.sendChat($("#chatmsg").val(), "message");
$("#chatmsg").val("");
});
......@@ -307,7 +303,19 @@ var callbacks = {
displayID: "#conf_display",
dialog: dialog,
hasVid: check_vid(),
laData: data.pvtData
laData: data.pvtData,
chatCallback: function(v, e) {
console.log(e);
var from = e.data.fromDisplay || e.data.from || "Unknown";
var message = e.data.message || "";
$('#chatwin')
.append($('<span class="chatuid" />').text(from + ':'))
.append($('<br />'))
.append(messageTextToJQ(message))
.append($('<br />'));
$('#chatwin').animate({"scrollTop": $('#chatwin')[0].scrollHeight}, "fast");
}
});
if (!data.pvtData.canvasCount) {
......@@ -366,7 +374,7 @@ var callbacks = {
$("#message").show();
}
chatting_with = data.pvtData.chatID;
chatting_with = data.pvtData.chatChannel;
}
break;
......
......@@ -212,6 +212,68 @@ void conference_event_mod_channel_handler(const char *event_channel, cJSON *json
}
void conference_event_chat_channel_handler(const char *event_channel, cJSON *json, const char *key, switch_event_channel_id_t id)
{
cJSON *data;
cJSON *jid = 0;
const char *type = NULL;
const char *action = NULL;
cJSON *msg;
char *conference_name = strdup(event_channel + 15);
char *message = NULL;
cJSON *jdata;
char *p;
const char *uid = NULL;
const char *display = NULL;
if (conference_name && (p = strchr(conference_name, '@'))) {
*p = '\0';
}
uid = cJSON_GetObjectCstr(json, "userid");
display = cJSON_GetObjectCstr(json, "fromDisplay");
if ((data = cJSON_GetObjectItem(json, "data"))) {
type = cJSON_GetObjectCstr(data, "type");
action = cJSON_GetObjectCstr(data, "action");
if ((jid = cJSON_GetObjectItem(data, "message"))) {
if (!zstr(jid->valuestring)) {
message = jid->valuestring;
}
}
}
if (action && !strcasecmp(action, "send")) {
msg = cJSON_CreateObject();
jdata = json_add_child_obj(msg, "data", NULL);
cJSON_AddItemToObject(msg, "eventChannel", cJSON_CreateString(event_channel));
cJSON_AddItemToObject(jdata, "direction", cJSON_CreateString("outbound"));
if (message) {
cJSON_AddItemToObject(jdata, "message", cJSON_CreateString(message));
}
if (display) {
cJSON_AddItemToObject(jdata, "fromDisplay", cJSON_CreateString(display));
}
if (uid) {
cJSON_AddItemToObject(jdata, "from", cJSON_CreateString(uid));
}
if (type) {
cJSON_AddItemToObject(jdata, "type", cJSON_CreateString(type));
} else {
cJSON_AddItemToObject(jdata, "type", cJSON_CreateString("message"));
}
switch_event_channel_broadcast(event_channel, &msg, __FILE__, conference_globals.event_channel_id);
}
switch_safe_free(conference_name);
}
void conference_event_la_channel_handler(const char *event_channel, cJSON *json, const char *key, switch_event_channel_id_t id)
{
switch_live_array_parse_json(json, conference_globals.event_channel_id);
......@@ -347,6 +409,8 @@ void conference_event_adv_la(conference_obj_t *conference, conference_member_t *
cJSON_AddItemToObject(data, "modChannel", cJSON_CreateString(conference->mod_event_channel));
}
cJSON_AddItemToObject(data, "chatChannel", cJSON_CreateString(conference->chat_event_channel));
switch_core_get_variables(&variables);
for (hp = variables->headers; hp; hp = hp->next) {
if (!strncasecmp(hp->name, "conference_verto_", 11)) {
......@@ -363,6 +427,7 @@ void conference_event_adv_la(conference_obj_t *conference, conference_member_t *
if (cookie) {
switch_event_channel_permission_modify(cookie, conference->la_event_channel, join);
switch_event_channel_permission_modify(cookie, conference->mod_event_channel, join);
switch_event_channel_permission_modify(cookie, conference->chat_event_channel, join);
}
}
}
......
......@@ -242,9 +242,11 @@ void *SWITCH_THREAD_FUNC conference_thread_run(switch_thread_t *thread, void *ob
if (strchr(conference->name, '@')) {
conference->la_event_channel = switch_core_sprintf(conference->pool, "conference-liveArray.%s", conference->name);
conference->chat_event_channel = switch_core_sprintf(conference->pool, "conference-chat.%s", conference->name);
conference->mod_event_channel = switch_core_sprintf(conference->pool, "conference-mod.%s", conference->name);
} else {
conference->la_event_channel = switch_core_sprintf(conference->pool, "conference-liveArray.%s@%s", conference->name, conference->domain);
conference->chat_event_channel = switch_core_sprintf(conference->pool, "conference-chat.%s@%s", conference->name, conference->domain);
conference->mod_event_channel = switch_core_sprintf(conference->pool, "conference-mod.%s@%s", conference->name, conference->domain);
}
......@@ -3303,6 +3305,7 @@ SWITCH_MODULE_LOAD_FUNCTION(mod_conference_load)
switch_event_channel_bind("conference", conference_event_channel_handler, &conference_globals.event_channel_id);
switch_event_channel_bind("conference-liveArray", conference_event_la_channel_handler, &conference_globals.event_channel_id);
switch_event_channel_bind("conference-mod", conference_event_mod_channel_handler, &conference_globals.event_channel_id);
switch_event_channel_bind("conference-chat", conference_event_chat_channel_handler, &conference_globals.event_channel_id);
if ( conference_api_sub_syntax(&api_syntax) != SWITCH_STATUS_SUCCESS) {
return SWITCH_STATUS_TERM;
......@@ -3358,6 +3361,8 @@ SWITCH_MODULE_SHUTDOWN_FUNCTION(mod_conference_shutdown)
switch_event_channel_unbind(NULL, conference_event_channel_handler);
switch_event_channel_unbind(NULL, conference_event_la_channel_handler);
switch_event_channel_unbind(NULL, conference_event_mod_channel_handler);
switch_event_channel_unbind(NULL, conference_event_chat_channel_handler);
switch_console_del_complete_func("::conference::conference_list_conferences");
......
......@@ -515,6 +515,7 @@ typedef struct conference_obj {
char *name;
char *la_name;
char *la_event_channel;
char *chat_event_channel;
char *mod_event_channel;
char *desc;
char *timer_name;
......@@ -1002,7 +1003,7 @@ void conference_cdr_render(conference_obj_t *conference);
void conference_event_channel_handler(const char *event_channel, cJSON *json, const char *key, switch_event_channel_id_t id);
void conference_event_la_channel_handler(const char *event_channel, cJSON *json, const char *key, switch_event_channel_id_t id);
void conference_event_mod_channel_handler(const char *event_channel, cJSON *json, const char *key, switch_event_channel_id_t id);
void conference_event_chat_channel_handler(const char *event_channel, cJSON *json, const char *key, switch_event_channel_id_t id);
void conference_member_itterator(conference_obj_t *conference, switch_stream_handle_t *stream, uint8_t non_mod, conference_api_member_cmd_t pfncallback, void *data);
......
......@@ -3386,8 +3386,10 @@ static switch_bool_t verto__invite_func(const char *method, cJSON *params, jsock
if ((var = switch_event_get_header(jsock->params, "caller-id-name"))) {
caller_id_name = var;
}
} else if (caller_id_name) {
switch_event_add_header_string(jsock->params, SWITCH_STACK_BOTTOM, "caller-id-name", caller_id_name);
}
if (zstr(caller_id_number)) {
if ((var = switch_event_get_header(jsock->params, "caller-id-number"))) {
caller_id_number = var;
......@@ -3647,6 +3649,7 @@ static switch_bool_t verto__broadcast_func(const char *method, cJSON *params, js
switch_bool_t r = SWITCH_FALSE;
const char *event_channel = cJSON_GetObjectCstr(params, "eventChannel");
cJSON *jevent;
const char *display = NULL;
*response = cJSON_CreateObject();
......@@ -3666,6 +3669,11 @@ static switch_bool_t verto__broadcast_func(const char *method, cJSON *params, js
cJSON_AddItemToObject(params, "userid", cJSON_CreateString(jsock->uid));
display = switch_event_get_header(jsock->params, "caller-id-name");
if (display) {
cJSON_AddItemToObject(params, "fromDisplay", cJSON_CreateString(display));
}
jevent = cJSON_Duplicate(params, 1);
switch_event_channel_broadcast(event_channel, &jevent, modname, globals.event_channel_id);
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论