diff --git a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/EjectAllUsersFromVoiceConfRequestMessage.java b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/EjectAllUsersFromVoiceConfRequestMessage.java new file mode 100755 index 000000000000..28ba956a06ad --- /dev/null +++ b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/EjectAllUsersFromVoiceConfRequestMessage.java @@ -0,0 +1,56 @@ +package org.bigbluebutton.common.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class EjectAllUsersFromVoiceConfRequestMessage { + public static final String EJECT_ALL_VOICE_USERS_REQUEST = "eject_all_users_from_voice_conf_request_message"; + public static final String VERSION = "0.0.1"; + + public static final String MEETING_ID = "meeting_id"; + public static final String VOICE_CONF_ID = "voice_conf_id"; + + public final String meetingId; + public final String voiceConfId; + + public EjectAllUsersFromVoiceConfRequestMessage(String meetingId, String voiceConfId) { + this.meetingId = meetingId; + this.voiceConfId = voiceConfId; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(MEETING_ID, meetingId); + payload.put(VOICE_CONF_ID, voiceConfId); + + java.util.HashMap header = MessageBuilder.buildHeader(EJECT_ALL_VOICE_USERS_REQUEST, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static EjectAllUsersFromVoiceConfRequestMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (EJECT_ALL_VOICE_USERS_REQUEST.equals(messageName)) { + if (payload.has(MEETING_ID) + && payload.has(VOICE_CONF_ID)) { + String id = payload.get(MEETING_ID).getAsString(); + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + return new EjectAllUsersFromVoiceConfRequestMessage(id, voiceConfId); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/EjectUserFromVoiceConfRequestMessage.java b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/EjectUserFromVoiceConfRequestMessage.java new file mode 100755 index 000000000000..d9fd40168711 --- /dev/null +++ b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/EjectUserFromVoiceConfRequestMessage.java @@ -0,0 +1,62 @@ +package org.bigbluebutton.common.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class EjectUserFromVoiceConfRequestMessage { + public static final String EJECT_VOICE_USER_REQUEST = "eject_user_from_voice_conf_request_message"; + public static final String VERSION = "0.0.1"; + + public static final String MEETING_ID = "meeting_id"; + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String VOICE_USER_ID = "voice_user_id"; + + public final String meetingId; + public final String voiceConfId; + public final String voiceUserId; + + public EjectUserFromVoiceConfRequestMessage(String meetingId, String voiceConfId, String voiceUserId) { + this.meetingId = meetingId; + this.voiceConfId = voiceConfId; + this.voiceUserId = voiceUserId; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(MEETING_ID, meetingId); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(VOICE_USER_ID, voiceUserId); + + java.util.HashMap header = MessageBuilder.buildHeader(EJECT_VOICE_USER_REQUEST, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static EjectUserFromVoiceConfRequestMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (EJECT_VOICE_USER_REQUEST.equals(messageName)) { + if (payload.has(MEETING_ID) + && payload.has(VOICE_CONF_ID) + && payload.has(VOICE_USER_ID)) { + String id = payload.get(MEETING_ID).getAsString(); + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String voiceUserId = payload.get(VOICE_USER_ID).getAsString(); + return new EjectUserFromVoiceConfRequestMessage(id, voiceConfId, voiceUserId); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/GetUsersFromVoiceConfRequestMessage.java b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/GetUsersFromVoiceConfRequestMessage.java new file mode 100755 index 000000000000..8e295656c04f --- /dev/null +++ b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/GetUsersFromVoiceConfRequestMessage.java @@ -0,0 +1,56 @@ +package org.bigbluebutton.common.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class GetUsersFromVoiceConfRequestMessage { + public static final String GET_VOICE_USERS_REQUEST = "get_users_from_voice_conf_request_message"; + public static final String VERSION = "0.0.1"; + + public static final String MEETING_ID = "meeting_id"; + public static final String VOICE_CONF_ID = "voice_conf_id"; + + public final String meetingId; + public final String voiceConfId; + + public GetUsersFromVoiceConfRequestMessage(String meetingId, String voiceConfId) { + this.meetingId = meetingId; + this.voiceConfId = voiceConfId; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(MEETING_ID, meetingId); + payload.put(VOICE_CONF_ID, voiceConfId); + + java.util.HashMap header = MessageBuilder.buildHeader(GET_VOICE_USERS_REQUEST, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static GetUsersFromVoiceConfRequestMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (GET_VOICE_USERS_REQUEST.equals(messageName)) { + if (payload.has(MEETING_ID) + && payload.has(VOICE_CONF_ID)) { + String id = payload.get(MEETING_ID).getAsString(); + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + return new GetUsersFromVoiceConfRequestMessage(id, voiceConfId); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/MessagingConstants.java b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/MessagingConstants.java index d762cac491ac..96f8d341c320 100755 --- a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/MessagingConstants.java +++ b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/MessagingConstants.java @@ -41,6 +41,13 @@ public class MessagingConstants { public static final String TO_VOICE_CHANNEL = TO_BBB_APPS_CHANNEL + ":voice"; public static final String TO_WHITEBOARD_CHANNEL = TO_BBB_APPS_CHANNEL + ":whiteboard"; + public static final String TO_VOICE_CONF_CHANNEL = "bigbluebutton:to-voice-conf"; + public static final String TO_VOICE_CONF_PATTERN = TO_VOICE_CONF_CHANNEL + ":*"; + public static final String TO_VOICE_CONF_SYSTEM_CHAN = TO_VOICE_CONF_CHANNEL + ":system"; + public static final String FROM_VOICE_CONF_CHANNEL = "bigbluebutton:from-voice-conf"; + public static final String FROM_VOICE_CONF_PATTERN = FROM_VOICE_CONF_CHANNEL + ":*"; + public static final String FROM_VOICE_CONF_SYSTEM_CHAN = FROM_VOICE_CONF_CHANNEL + ":system"; + public static final String DESTROY_MEETING_REQUEST_EVENT = "DestroyMeetingRequestEvent"; public static final String CREATE_MEETING_REQUEST_EVENT = "CreateMeetingRequestEvent"; public static final String END_MEETING_REQUEST_EVENT = "EndMeetingRequestEvent"; diff --git a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/MuteUserInVoiceConfRequestMessage.java b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/MuteUserInVoiceConfRequestMessage.java new file mode 100755 index 000000000000..4f45cef8e15a --- /dev/null +++ b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/MuteUserInVoiceConfRequestMessage.java @@ -0,0 +1,68 @@ +package org.bigbluebutton.common.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class MuteUserInVoiceConfRequestMessage { + public static final String MUTE_VOICE_USER_REQUEST = "mute_user_in_voice_conf_request_message"; + public static final String VERSION = "0.0.1"; + + public static final String MEETING_ID = "meeting_id"; + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String VOICE_USER_ID = "voice_user_id"; + public static final String MUTE = "mute"; + + public final String meetingId; + public final String voiceConfId; + public final String voiceUserId; + public final Boolean mute; + + public MuteUserInVoiceConfRequestMessage(String meetingId, String voiceConfId, String voiceUserId, Boolean mute) { + this.meetingId = meetingId; + this.voiceConfId = voiceConfId; + this.voiceUserId = voiceUserId; + this.mute = mute; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(MEETING_ID, meetingId); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(VOICE_USER_ID, voiceUserId); + payload.put(MUTE, mute); + + java.util.HashMap header = MessageBuilder.buildHeader(MUTE_VOICE_USER_REQUEST, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static MuteUserInVoiceConfRequestMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (MUTE_VOICE_USER_REQUEST.equals(messageName)) { + if (payload.has(MEETING_ID) + && payload.has(VOICE_CONF_ID) + && payload.has(VOICE_USER_ID) + && payload.has(MUTE)) { + String id = payload.get(MEETING_ID).getAsString(); + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String voiceUserId = payload.get(VOICE_USER_ID).getAsString(); + Boolean mute = payload.get(MUTE).getAsBoolean(); + return new MuteUserInVoiceConfRequestMessage(id, voiceConfId, voiceUserId, mute); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/RecordVoiceConfRequestMessage.java b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/RecordVoiceConfRequestMessage.java new file mode 100755 index 000000000000..4158afea2214 --- /dev/null +++ b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/RecordVoiceConfRequestMessage.java @@ -0,0 +1,62 @@ +package org.bigbluebutton.common.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class RecordVoiceConfRequestMessage { + public static final String RECORD_VOICE_CONF_REQUEST = "record_voice_conf_request_message"; + public static final String VERSION = "0.0.1"; + + public static final String MEETING_ID = "meeting_id"; + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String RECORD = "record"; + + public final String meetingId; + public final String voiceConfId; + public final Boolean record; + + public RecordVoiceConfRequestMessage(String meetingId, String voiceConfId, Boolean record) { + this.meetingId = meetingId; + this.voiceConfId = voiceConfId; + this.record = record; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(MEETING_ID, meetingId); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(RECORD, record); + + java.util.HashMap header = MessageBuilder.buildHeader(RECORD_VOICE_CONF_REQUEST, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static RecordVoiceConfRequestMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (RECORD_VOICE_CONF_REQUEST.equals(messageName)) { + if (payload.has(MEETING_ID) + && payload.has(VOICE_CONF_ID) + && payload.has(RECORD)) { + String id = payload.get(MEETING_ID).getAsString(); + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + Boolean record = payload.get(RECORD).getAsBoolean(); + return new RecordVoiceConfRequestMessage(id, voiceConfId, record); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/StartRecordingVoiceConfRequestMessage.java b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/StartRecordingVoiceConfRequestMessage.java new file mode 100755 index 000000000000..12e706f85884 --- /dev/null +++ b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/StartRecordingVoiceConfRequestMessage.java @@ -0,0 +1,56 @@ +package org.bigbluebutton.common.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class StartRecordingVoiceConfRequestMessage { + public static final String START_RECORD_VOICE_CONF_REQUEST = "start_recording__voice_conf_request_message"; + public static final String VERSION = "0.0.1"; + + public static final String MEETING_ID = "meeting_id"; + public static final String VOICE_CONF_ID = "voice_conf_id"; + + public final String meetingId; + public final String voiceConfId; + + public StartRecordingVoiceConfRequestMessage(String meetingId, String voiceConfId) { + this.meetingId = meetingId; + this.voiceConfId = voiceConfId; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(MEETING_ID, meetingId); + payload.put(VOICE_CONF_ID, voiceConfId); + + java.util.HashMap header = MessageBuilder.buildHeader(START_RECORD_VOICE_CONF_REQUEST, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static StartRecordingVoiceConfRequestMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (START_RECORD_VOICE_CONF_REQUEST.equals(messageName)) { + if (payload.has(MEETING_ID) + && payload.has(VOICE_CONF_ID)) { + String id = payload.get(MEETING_ID).getAsString(); + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + return new StartRecordingVoiceConfRequestMessage(id, voiceConfId); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/StopRecordingVoiceConfRequestMessage.java b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/StopRecordingVoiceConfRequestMessage.java new file mode 100755 index 000000000000..fb84f12ef669 --- /dev/null +++ b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/StopRecordingVoiceConfRequestMessage.java @@ -0,0 +1,62 @@ +package org.bigbluebutton.common.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class StopRecordingVoiceConfRequestMessage { + public static final String RECORD_VOICE_CONF_REQUEST = "stop_recording_voice_conf_request_message"; + public static final String VERSION = "0.0.1"; + + public static final String MEETING_ID = "meeting_id"; + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String RECORD_STREAM = "record_stream"; + + public final String meetingId; + public final String voiceConfId; + public final String recordStream; + + public StopRecordingVoiceConfRequestMessage(String meetingId, String voiceConfId, String recordStream) { + this.meetingId = meetingId; + this.voiceConfId = voiceConfId; + this.recordStream = recordStream; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(MEETING_ID, meetingId); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(RECORD_STREAM, recordStream); + + java.util.HashMap header = MessageBuilder.buildHeader(RECORD_VOICE_CONF_REQUEST, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static StopRecordingVoiceConfRequestMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (RECORD_VOICE_CONF_REQUEST.equals(messageName)) { + if (payload.has(MEETING_ID) + && payload.has(VOICE_CONF_ID) + && payload.has(RECORD_STREAM)) { + String id = payload.get(MEETING_ID).getAsString(); + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String recordStream = payload.get(RECORD_STREAM).getAsString(); + return new StopRecordingVoiceConfRequestMessage(id, voiceConfId, recordStream); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/UserJoinedVoiceConfMessage.java b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/UserJoinedVoiceConfMessage.java new file mode 100755 index 000000000000..cf8319dab097 --- /dev/null +++ b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/UserJoinedVoiceConfMessage.java @@ -0,0 +1,87 @@ +package org.bigbluebutton.common.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class UserJoinedVoiceConfMessage { + public static final String USER_JOINED_VOICE_CONF = "user_joined_voice_conf_message"; + public static final String VERSION = "0.0.1"; + + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String VOICE_USER_ID = "voice_user_id"; + public static final String USER_ID = "user_id"; + public static final String CALLER_ID_NAME = "caller_id_name"; + public static final String CALLER_ID_NUM = "caller_id_num"; + public static final String MUTED = "muted"; + public static final String TALKING = "talking"; + + public final String voiceConfId; + public final String voiceUserId; + public final String userId; + public final String callerIdName; + public final String callerIdNum; + public final Boolean muted; + public final Boolean talking; + + public UserJoinedVoiceConfMessage(String voiceConfId, String voiceUserId, String userId, + String callerIdName, String callerIdNum, Boolean muted, Boolean talking) { + this.voiceConfId = voiceConfId; + this.voiceUserId = voiceUserId; + this.userId = userId; + this.callerIdName = callerIdName; + this.callerIdNum = callerIdNum; + this.muted = muted; + this.talking = talking; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(VOICE_USER_ID, voiceUserId); + payload.put(USER_ID, userId); + payload.put(CALLER_ID_NAME, callerIdName); + payload.put(CALLER_ID_NUM, callerIdNum); + payload.put(MUTED, muted); + payload.put(TALKING, talking); + + java.util.HashMap header = MessageBuilder.buildHeader(USER_JOINED_VOICE_CONF, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static UserJoinedVoiceConfMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (USER_JOINED_VOICE_CONF.equals(messageName)) { + if (payload.has(VOICE_CONF_ID) + && payload.has(VOICE_USER_ID) + && payload.has(USER_ID) + && payload.has(CALLER_ID_NAME) + && payload.has(CALLER_ID_NUM) + && payload.has(MUTED) + && payload.has(TALKING)) { + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String voiceUserId = payload.get(VOICE_USER_ID).getAsString(); + String userId = payload.get(USER_ID).getAsString(); + String callerIdName = payload.get(CALLER_ID_NAME).getAsString(); + String callerIdNum = payload.get(CALLER_ID_NUM).getAsString(); + Boolean muted = payload.get(MUTED).getAsBoolean(); + Boolean talking = payload.get(TALKING).getAsBoolean(); + return new UserJoinedVoiceConfMessage(voiceConfId, voiceUserId, userId, callerIdName, callerIdNum, muted, talking); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/UserLeftVoiceConfMessage.java b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/UserLeftVoiceConfMessage.java new file mode 100755 index 000000000000..fe94818eb40c --- /dev/null +++ b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/UserLeftVoiceConfMessage.java @@ -0,0 +1,56 @@ +package org.bigbluebutton.common.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class UserLeftVoiceConfMessage { + public static final String USER_LEFT_VOICE_CONF = "user_left_voice_conf_message"; + public static final String VERSION = "0.0.1"; + + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String VOICE_USER_ID = "voice_user_id"; + + public final String voiceConfId; + public final String voiceUserId; + + public UserLeftVoiceConfMessage(String voiceConfId, String voiceUserId) { + this.voiceConfId = voiceConfId; + this.voiceUserId = voiceUserId; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(VOICE_USER_ID, voiceUserId); + + java.util.HashMap header = MessageBuilder.buildHeader(USER_LEFT_VOICE_CONF, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static UserLeftVoiceConfMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (USER_LEFT_VOICE_CONF.equals(messageName)) { + if (payload.has(VOICE_CONF_ID) + && payload.has(VOICE_USER_ID)) { + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String voiceUserId = payload.get(VOICE_USER_ID).getAsString(); + return new UserLeftVoiceConfMessage(voiceConfId, voiceUserId); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/UserLockedInVoiceConfMessage.java b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/UserLockedInVoiceConfMessage.java new file mode 100755 index 000000000000..d9fb7b85e110 --- /dev/null +++ b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/UserLockedInVoiceConfMessage.java @@ -0,0 +1,62 @@ +package org.bigbluebutton.common.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class UserLockedInVoiceConfMessage { + public static final String USER_LOCKED_IN_VOICE_CONF = "user_locked_in_voice_conf_message"; + public static final String VERSION = "0.0.1"; + + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String VOICE_USER_ID = "voice_user_id"; + public static final String LOCKED = "locked"; + + public final String voiceConfId; + public final String voiceUserId; + public final Boolean locked; + + public UserLockedInVoiceConfMessage(String voiceConfId, String voiceUserId, Boolean locked) { + this.voiceConfId = voiceConfId; + this.voiceUserId = voiceUserId; + this.locked = locked; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(VOICE_USER_ID, voiceUserId); + payload.put(LOCKED, locked); + + java.util.HashMap header = MessageBuilder.buildHeader(USER_LOCKED_IN_VOICE_CONF, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static UserLockedInVoiceConfMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (USER_LOCKED_IN_VOICE_CONF.equals(messageName)) { + if (payload.has(VOICE_CONF_ID) + && payload.has(VOICE_USER_ID) + && payload.has(LOCKED)) { + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String voiceUserId = payload.get(VOICE_USER_ID).getAsString(); + Boolean locked = payload.get(LOCKED).getAsBoolean(); + return new UserLockedInVoiceConfMessage(voiceConfId, voiceUserId, locked); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/UserMutedInVoiceConfMessage.java b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/UserMutedInVoiceConfMessage.java new file mode 100755 index 000000000000..cb87b8c98bdc --- /dev/null +++ b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/UserMutedInVoiceConfMessage.java @@ -0,0 +1,62 @@ +package org.bigbluebutton.common.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class UserMutedInVoiceConfMessage { + public static final String USER_MUTED_IN_VOICE_CONF = "user_muted_in_voice_conf_message"; + public static final String VERSION = "0.0.1"; + + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String VOICE_USER_ID = "voice_user_id"; + public static final String MUTED = "muted"; + + public final String voiceConfId; + public final String voiceUserId; + public final Boolean muted; + + public UserMutedInVoiceConfMessage(String voiceConfId, String voiceUserId, Boolean muted) { + this.voiceConfId = voiceConfId; + this.voiceUserId = voiceUserId; + this.muted = muted; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(VOICE_USER_ID, voiceUserId); + payload.put(MUTED, muted); + + java.util.HashMap header = MessageBuilder.buildHeader(USER_MUTED_IN_VOICE_CONF, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static UserMutedInVoiceConfMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (USER_MUTED_IN_VOICE_CONF.equals(messageName)) { + if (payload.has(VOICE_CONF_ID) + && payload.has(VOICE_USER_ID) + && payload.has(MUTED)) { + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String voiceUserId = payload.get(VOICE_USER_ID).getAsString(); + Boolean muted = payload.get(MUTED).getAsBoolean(); + return new UserMutedInVoiceConfMessage(voiceConfId, voiceUserId, muted); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/UserTalkingInVoiceConfMessage.java b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/UserTalkingInVoiceConfMessage.java new file mode 100755 index 000000000000..461337e16de1 --- /dev/null +++ b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/UserTalkingInVoiceConfMessage.java @@ -0,0 +1,62 @@ +package org.bigbluebutton.common.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class UserTalkingInVoiceConfMessage { + public static final String USER_TALKING_IN_VOICE_CONF = "user_talking_in_voice_conf_message"; + public static final String VERSION = "0.0.1"; + + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String VOICE_USER_ID = "voice_user_id"; + public static final String TALKING = "talking"; + + public final String voiceConfId; + public final String voiceUserId; + public final Boolean talking; + + public UserTalkingInVoiceConfMessage(String voiceConfId, String voiceUserId, Boolean talking) { + this.voiceConfId = voiceConfId; + this.voiceUserId = voiceUserId; + this.talking = talking; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(VOICE_USER_ID, voiceUserId); + payload.put(TALKING, talking); + + java.util.HashMap header = MessageBuilder.buildHeader(USER_TALKING_IN_VOICE_CONF, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static UserTalkingInVoiceConfMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (USER_TALKING_IN_VOICE_CONF.equals(messageName)) { + if (payload.has(VOICE_CONF_ID) + && payload.has(VOICE_USER_ID) + && payload.has(TALKING)) { + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String voiceUserId = payload.get(VOICE_USER_ID).getAsString(); + Boolean talking = payload.get(TALKING).getAsBoolean(); + return new UserTalkingInVoiceConfMessage(voiceConfId, voiceUserId, talking); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/VoiceConfRecordingStartedMessage.java b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/VoiceConfRecordingStartedMessage.java new file mode 100755 index 000000000000..6bd2dd455c55 --- /dev/null +++ b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/common/messages/VoiceConfRecordingStartedMessage.java @@ -0,0 +1,69 @@ +package org.bigbluebutton.common.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class VoiceConfRecordingStartedMessage { + public static final String VOICE_CONF_RECORDING_STARTED = "voice_conf_recording_started_message"; + public static final String VERSION = "0.0.1"; + + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String RECORD_STREAM = "record_stream"; + public static final String RECORDING = "recording"; + public static final String TIMESTAMP = "timestamp"; + + public final String voiceConfId; + public final String recordStream; + public final Boolean recording; + public final String timestamp; + + public VoiceConfRecordingStartedMessage(String voiceConfId, + String recordStream, Boolean recording, String timestamp) { + this.voiceConfId = voiceConfId; + this.recordStream = recordStream; + this.recording = recording; + this.timestamp = timestamp; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(RECORD_STREAM, recordStream); + payload.put(RECORDING, recording); + payload.put(TIMESTAMP, timestamp); + + java.util.HashMap header = MessageBuilder.buildHeader(VOICE_CONF_RECORDING_STARTED, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static VoiceConfRecordingStartedMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (VOICE_CONF_RECORDING_STARTED.equals(messageName)) { + if (payload.has(VOICE_CONF_ID) + && payload.has(RECORD_STREAM) + && payload.has(RECORDING) + && payload.has(TIMESTAMP)) { + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String recordStream = payload.get(RECORD_STREAM).getAsString(); + Boolean recording = payload.get(RECORDING).getAsBoolean(); + String timestamp = payload.get(TIMESTAMP).getAsString(); + return new VoiceConfRecordingStartedMessage(voiceConfId, recordStream, recording, timestamp); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/core/api/IBigBlueButtonInGW.java b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/core/api/IBigBlueButtonInGW.java index 87c17e28c12a..f72392105a74 100755 --- a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/core/api/IBigBlueButtonInGW.java +++ b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/core/api/IBigBlueButtonInGW.java @@ -52,9 +52,8 @@ void createMeeting2(String meetingID, String externalMeetingID, String meetingNa void lockMuteUser(String meetingID, String requesterID, String userID, Boolean lock); void ejectUserFromVoice(String meetingID, String userId, String ejectedBy); void ejectUserFromMeeting(String meetingId, String userId, String ejectedBy); - void voiceUserJoined(String meetingId, String userId, String webUserId, String conference, - String callerIdNum, String callerIdName, - Boolean muted, Boolean speaking); + void voiceUserJoined(String voiceConfId, String voiceUserId, String userId, String callerIdName, + String callerIdNum, Boolean muted, Boolean talking); void voiceUserLeft(String meetingId, String userId); void voiceUserLocked(String meetingId, String userId, Boolean locked); void voiceUserMuted(String meetingId, String userId, Boolean muted); diff --git a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/core/pubsub/receivers/UsersMessageReceiver.java b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/core/pubsub/receivers/UsersMessageReceiver.java index 6ec01c2a767f..2b09f0d328ea 100755 --- a/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/core/pubsub/receivers/UsersMessageReceiver.java +++ b/labs/akka-bbb-apps/src/main/java/org/bigbluebutton/core/pubsub/receivers/UsersMessageReceiver.java @@ -19,11 +19,17 @@ import org.bigbluebutton.common.messages.MuteUserRequestMessage; import org.bigbluebutton.common.messages.SetRecordingStatusRequestMessage; import org.bigbluebutton.common.messages.SetUserStatusRequestMessage; +import org.bigbluebutton.common.messages.UserJoinedVoiceConfMessage; import org.bigbluebutton.common.messages.UserLeavingMessage; +import org.bigbluebutton.common.messages.UserLeftVoiceConfMessage; +import org.bigbluebutton.common.messages.UserLockedInVoiceConfMessage; import org.bigbluebutton.common.messages.UserLoweredHandMessage; +import org.bigbluebutton.common.messages.UserMutedInVoiceConfMessage; import org.bigbluebutton.common.messages.UserRaisedHandMessage; import org.bigbluebutton.common.messages.UserShareWebcamRequestMessage; +import org.bigbluebutton.common.messages.UserTalkingInVoiceConfMessage; import org.bigbluebutton.common.messages.UserUnshareWebcamRequestMessage; +import org.bigbluebutton.common.messages.VoiceConfRecordingStartedMessage; import org.bigbluebutton.core.api.IBigBlueButtonInGW; import com.google.gson.JsonParser; @@ -119,6 +125,79 @@ public void handleMessage(String pattern, String channel, String message) { } } } + } else if (channel.equalsIgnoreCase(MessagingConstants.FROM_VOICE_CONF_SYSTEM_CHAN)) { + System.out.println("Voice message: " + channel + " " + message); + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + switch (messageName) { + case UserJoinedVoiceConfMessage.USER_JOINED_VOICE_CONF: + processUserJoinedVoiceConfMessage(message); + break; + case UserLeftVoiceConfMessage.USER_LEFT_VOICE_CONF: + processUserLeftVoiceConfMessage(message); + break; + case UserLockedInVoiceConfMessage.USER_LOCKED_IN_VOICE_CONF: + processUserLockedInVoiceConfMessage(message); + break; + case UserMutedInVoiceConfMessage.USER_MUTED_IN_VOICE_CONF: + processUserMutedInVoiceConfMessage(message); + break; + case UserTalkingInVoiceConfMessage.USER_TALKING_IN_VOICE_CONF: + processUserTalkingInVoiceConfMessage(message); + break; + case VoiceConfRecordingStartedMessage.VOICE_CONF_RECORDING_STARTED: + processVoiceConfRecordingStartedMessage(message); + break; + } + } + } + } + } + + private void processUserJoinedVoiceConfMessage(String json) { + UserJoinedVoiceConfMessage msg = UserJoinedVoiceConfMessage.fromJson(json); + if (msg != null) { + bbbInGW.voiceUserJoined(msg.voiceConfId, msg.voiceUserId, msg.userId, msg.callerIdName, msg.callerIdNum, msg.muted, msg.talking); + } + } + + private void processUserLeftVoiceConfMessage(String json) { + UserLeftVoiceConfMessage msg = UserLeftVoiceConfMessage.fromJson(json); + if (msg != null) { + bbbInGW.voiceUserLeft(msg.voiceConfId, msg.voiceUserId); + } + } + + private void processUserLockedInVoiceConfMessage(String json) { + UserLockedInVoiceConfMessage msg = UserLockedInVoiceConfMessage.fromJson(json); + if (msg != null) { + bbbInGW.voiceUserLocked(msg.voiceConfId, msg.voiceUserId, msg.locked); + } + } + + private void processUserMutedInVoiceConfMessage(String json) { + UserMutedInVoiceConfMessage msg = UserMutedInVoiceConfMessage.fromJson(json); + if (msg != null) { + bbbInGW.voiceUserMuted(msg.voiceConfId, msg.voiceUserId, msg.muted); + } + } + + private void processUserTalkingInVoiceConfMessage(String json) { + UserTalkingInVoiceConfMessage msg = UserTalkingInVoiceConfMessage.fromJson(json); + if (msg != null) { + bbbInGW.voiceUserTalking(msg.voiceConfId, msg.voiceUserId, msg.talking); + } + } + + private void processVoiceConfRecordingStartedMessage(String json) { + VoiceConfRecordingStartedMessage msg = VoiceConfRecordingStartedMessage.fromJson(json); + if (msg != null) { + bbbInGW.voiceRecording(msg.voiceConfId, msg.recordStream, msg.timestamp, msg.recording); } } diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonActor.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonActor.scala index b064d552df0a..ce50e5002ee4 100755 --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonActor.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonActor.scala @@ -23,7 +23,6 @@ class BigBlueButtonActor(val system: ActorSystem, outGW: MessageOutGateway) exte implicit def executionContext = actorRefFactory.dispatcher implicit val timeout = Timeout(5 seconds) - //private var meetings = new HashMap[String, MeetingActor] private var meetings = new collection.immutable.HashMap[String, RunningMeeting] def receive = { @@ -32,10 +31,56 @@ class BigBlueButtonActor(val system: ActorSystem, outGW: MessageOutGateway) exte case msg: KeepAliveMessage => handleKeepAliveMessage(msg) case msg: ValidateAuthToken => handleValidateAuthToken(msg) case msg: GetAllMeetingsRequest => handleGetAllMeetingsRequest(msg) + case msg: UserJoinedVoiceConfMessage => handleUserJoinedVoiceConfMessage(msg) + case msg: UserLeftVoiceConfMessage => handleUserLeftVoiceConfMessage(msg) + case msg: UserLockedInVoiceConfMessage => handleUserLockedInVoiceConfMessage(msg) + case msg: UserMutedInVoiceConfMessage => handleUserMutedInVoiceConfMessage(msg) + case msg: UserTalkingInVoiceConfMessage => handleUserTalkingInVoiceConfMessage(msg) + case msg: VoiceConfRecordingStartedMessage => handleVoiceConfRecordingStartedMessage(msg) case msg: InMessage => handleMeetingMessage(msg) case _ => // do nothing } + private def findMeetingWithVoiceConfId(voiceConfId: String): Option[RunningMeeting] = { + meetings.values.find(m => m.voiceBridge == voiceConfId) + } + + private def handleUserJoinedVoiceConfMessage(msg: UserJoinedVoiceConfMessage) { + val rm = findMeetingWithVoiceConfId(msg.voiceConfId) + + rm foreach { m => m.actorRef ! msg } + } + + private def handleUserLeftVoiceConfMessage(msg: UserLeftVoiceConfMessage) { + val rm = findMeetingWithVoiceConfId(msg.voiceConfId) + + rm foreach { m => m.actorRef ! msg } + } + + private def handleUserLockedInVoiceConfMessage(msg: UserLockedInVoiceConfMessage) { + val rm = findMeetingWithVoiceConfId(msg.voiceConfId) + + rm foreach { m => m.actorRef ! msg } + } + + private def handleUserMutedInVoiceConfMessage(msg: UserMutedInVoiceConfMessage) { + val rm = findMeetingWithVoiceConfId(msg.voiceConfId) + + rm foreach { m => m.actorRef ! msg } + } + + private def handleVoiceConfRecordingStartedMessage(msg: VoiceConfRecordingStartedMessage) { + val rm = findMeetingWithVoiceConfId(msg.voiceConfId) + + rm foreach { m => m.actorRef ! msg } + } + + private def handleUserTalkingInVoiceConfMessage(msg: UserTalkingInVoiceConfMessage) { + val rm = findMeetingWithVoiceConfId(msg.voiceConfId) + + rm foreach { m => m.actorRef ! msg } + } + private def handleValidateAuthToken(msg: ValidateAuthToken) { meetings.get(msg.meetingID) foreach { m => val future = m.actorRef.ask(msg)(5 seconds) diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonGateway.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonGateway.scala index f5a8a72335da..d59d48ea4b4a 100755 --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonGateway.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonGateway.scala @@ -6,8 +6,7 @@ import akka.actor.{ ActorSystem, Props } class BigBlueButtonGateway(system: ActorSystem, outGW: MessageOutGateway) { - val bbbActor = system.actorOf( - BigBlueButtonActor.props(system, outGW), "bigbluebutton-actor") + val bbbActor = system.actorOf(BigBlueButtonActor.props(system, outGW), "bigbluebutton-actor") def accept(msg: InMessage): Unit = { bbbActor ! msg @@ -17,4 +16,27 @@ class BigBlueButtonGateway(system: ActorSystem, outGW: MessageOutGateway) { bbbActor ! msg } + def acceptUserJoinedVoiceConfMessage(msg: UserJoinedVoiceConfMessage) { + bbbActor ! msg + } + + def acceptUserLeftVoiceConfMessage(msg: UserLeftVoiceConfMessage) { + bbbActor ! msg + } + + def acceptUserLockedInVoiceConfMessage(msg: UserLockedInVoiceConfMessage) { + bbbActor ! msg + } + + def acceptUserMutedInVoiceConfMessage(msg: UserMutedInVoiceConfMessage) { + bbbActor ! msg + } + + def acceptUserTalkingInVoiceConfMessage(msg: UserTalkingInVoiceConfMessage) { + bbbActor ! msg + } + + def acceptVoiceConfRecordingStartedMessage(msg: VoiceConfRecordingStartedMessage) { + bbbActor ! msg + } } diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonInGW.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonInGW.scala index 5ec213f9efc4..fe6e45cd0030 100755 --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonInGW.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/BigBlueButtonInGW.scala @@ -397,35 +397,29 @@ class BigBlueButtonInGW(bbbGW: BigBlueButtonGateway) extends IBigBlueButtonInGW voiceGW.ejectUserFromVoice(meetingId, userId, ejectedBy) } - def voiceUserJoined(meetingId: String, userId: String, webUserId: String, - conference: String, callerIdNum: String, - callerIdName: String, - muted: java.lang.Boolean, speaking: java.lang.Boolean) { + def voiceUserJoined(voiceConfId: String, voiceUserId: String, userId: String, callerIdName: String, + callerIdNum: String, muted: java.lang.Boolean, talking: java.lang.Boolean) { - voiceGW.voiceUserJoined(meetingId, userId, webUserId, - conference, callerIdNum, - callerIdName, muted, speaking) + voiceGW.voiceUserJoined(voiceConfId, voiceUserId, userId, callerIdName, callerIdNum, muted, talking) } - def voiceUserLeft(meetingId: String, userId: String) { - voiceGW.voiceUserLeft(meetingId, userId) + def voiceUserLeft(voiceConfId: String, voiceUserId: String) { + voiceGW.voiceUserLeft(voiceConfId, voiceUserId) } - def voiceUserLocked(meetingId: String, userId: String, locked: java.lang.Boolean) { - voiceGW.voiceUserLocked(meetingId, userId, locked) + def voiceUserLocked(voiceConfId: String, voiceUserId: String, locked: java.lang.Boolean) { + voiceGW.voiceUserLocked(voiceConfId, voiceUserId, locked) } - def voiceUserMuted(meetingId: String, userId: String, muted: java.lang.Boolean) { - voiceGW.voiceUserMuted(meetingId, userId, muted) + def voiceUserMuted(voiceConfId: String, voiceUserId: String, muted: java.lang.Boolean) { + voiceGW.voiceUserMuted(voiceConfId, voiceUserId, muted) } - def voiceUserTalking(meetingId: String, userId: String, talking: java.lang.Boolean) { - voiceGW.voiceUserTalking(meetingId, userId, talking) + def voiceUserTalking(voiceConfId: String, voiceUserId: String, talking: java.lang.Boolean) { + voiceGW.voiceUserTalking(voiceConfId, voiceUserId, talking) } - def voiceRecording(meetingId: String, recordingFile: String, - timestamp: String, recording: java.lang.Boolean) { - voiceGW.voiceRecording(meetingId, recordingFile, - timestamp, recording) + def voiceRecording(voiceConfId: String, recordingFile: String, timestamp: String, recording: java.lang.Boolean) { + voiceGW.voiceRecording(voiceConfId, recordingFile, timestamp, recording) } } diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/CollectorActor.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/CollectorActor.scala index 037858b0c278..efc68df9753d 100755 --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/CollectorActor.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/CollectorActor.scala @@ -68,12 +68,12 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { case msg: LockUserRequest => handleLockUserRequest(msg) case msg: EjectUserFromVoiceRequest => handleEjectUserFromVoiceRequest(msg) case msg: VoiceUserJoinedMessage => handleVoiceUserJoinedMessage(msg) - case msg: VoiceUserJoined => handleVoiceUserJoined(msg) - case msg: VoiceUserLeft => handleVoiceUserLeft(msg) - case msg: VoiceUserLocked => handleVoiceUserLocked(msg) - case msg: VoiceUserMuted => handleVoiceUserMuted(msg) - case msg: VoiceUserTalking => handleVoiceUserTalking(msg) - case msg: VoiceRecording => handleVoiceRecording(msg) + // case msg: VoiceUserJoined => handleVoiceUserJoined(msg) + // case msg: VoiceUserLeft => handleVoiceUserLeft(msg) + // case msg: VoiceUserLocked => handleVoiceUserLocked(msg) + // case msg: VoiceUserMuted => handleVoiceUserMuted(msg) + // case msg: VoiceUserTalking => handleVoiceUserTalking(msg) + // case msg: VoiceRecording => handleVoiceRecording(msg) case msg: SendWhiteboardAnnotationRequest => handleSendWhiteboardAnnotationRequest(msg) case msg: GetWhiteboardShapesRequest => handleGetWhiteboardShapesRequest(msg) case msg: ClearWhiteboardRequest => handleClearWhiteboardRequest(msg) @@ -945,6 +945,7 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { dispatcher.dispatch(buildJson(header, payload)) } + /* private def handleVoiceUserJoined(msg: VoiceUserJoined) { val payload = new java.util.HashMap[String, Any]() payload.put(Constants.MEETING_ID, msg.meetingID) @@ -958,7 +959,9 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { // println("***** DISPATCHING VOICE USER JOINED *****************") dispatcher.dispatch(buildJson(header, payload)) } +*/ + /* private def handleVoiceUserLeft(msg: VoiceUserLeft) { val payload = new java.util.HashMap[String, Any]() payload.put(Constants.MEETING_ID, msg.meetingID) @@ -972,7 +975,9 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { // println("***** DISPATCHING VOICE USER LEFT *****************") dispatcher.dispatch(buildJson(header, payload)) } +*/ + /* private def handleVoiceUserLocked(msg: VoiceUserLocked) { val payload = new java.util.HashMap[String, Any]() payload.put(Constants.MEETING_ID, msg.meetingID) @@ -987,7 +992,8 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { // println("***** DISPATCHING VOICE USER LOCKED *****************") dispatcher.dispatch(buildJson(header, payload)) } - +*/ + /* private def handleVoiceUserMuted(msg: VoiceUserMuted) { val payload = new java.util.HashMap[String, Any]() payload.put(Constants.MEETING_ID, msg.meetingID) @@ -1002,7 +1008,8 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { // println("***** DISPATCHING VOICE USER MUTED *****************") dispatcher.dispatch(buildJson(header, payload)) } - +*/ + /* private def handleVoiceUserTalking(msg: VoiceUserTalking) { val payload = new java.util.HashMap[String, Any]() payload.put(Constants.MEETING_ID, msg.meetingID) @@ -1017,7 +1024,8 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { // println("***** DISPATCHING VOICE USER TALKING *****************") dispatcher.dispatch(buildJson(header, payload)) } - +*/ + /* private def handleVoiceRecording(msg: VoiceRecording) { val payload = new java.util.HashMap[String, Any]() payload.put(Constants.MEETING_ID, msg.meetingID) @@ -1033,7 +1041,7 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { // println("***** DISPATCHING VOICE RECORDING *****************") dispatcher.dispatch(buildJson(header, payload)) } - +*/ private def handleSendWhiteboardAnnotationRequest(msg: SendWhiteboardAnnotationRequest) { val payload = new java.util.HashMap[String, Any]() payload.put(Constants.MEETING_ID, msg.meetingID) @@ -1429,7 +1437,7 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { payload.put(Constants.MEETING_ID, msg.meetingID) payload.put(Constants.RECORDED, msg.recorded) payload.put(Constants.USER_ID, msg.userId) - payload.put(Constants.REQUESTER_ID, msg.requesterID) + payload.put(Constants.VOICE_CONF_ID, msg.voiceConfId) payload.put(Constants.MUTE, msg.mute) val header = new java.util.HashMap[String, Any]() @@ -1478,7 +1486,7 @@ class CollectorActor(dispatcher: IDispatcher) extends Actor { payload.put(Constants.MEETING_ID, msg.meetingID) payload.put(Constants.RECORDED, msg.recorded) payload.put(Constants.USER_ID, msg.userId) - payload.put(Constants.REQUESTER_ID, msg.requesterID) + payload.put(Constants.VOICE_CONF_ID, msg.voiceConfId) val header = new java.util.HashMap[String, Any]() header.put(Constants.NAME, MessageNames.EJECT_VOICE_USER) diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/MeetingActor.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/MeetingActor.scala index 0897ae24384d..d6e781fcb082 100755 --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/MeetingActor.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/MeetingActor.scala @@ -66,10 +66,11 @@ class MeetingActor(val meetingID: String, val externalMeetingID: String, val mee case "MonitorNumberOfWebUsers" => handleMonitorNumberOfWebUsers() case msg: ValidateAuthToken => handleValidateAuthToken(msg) case msg: RegisterUser => handleRegisterUser(msg) - case msg: VoiceUserJoined => handleVoiceUserJoined(msg) - case msg: VoiceUserLeft => handleVoiceUserLeft(msg) - case msg: VoiceUserMuted => handleVoiceUserMuted(msg) - case msg: VoiceUserTalking => handleVoiceUserTalking(msg) + case msg: UserJoinedVoiceConfMessage => handleUserJoinedVoiceConfMessage(msg) + case msg: UserLeftVoiceConfMessage => handleUserLeftVoiceConfMessage(msg) + case msg: UserMutedInVoiceConfMessage => handleUserMutedInVoiceConfMessage(msg) + case msg: UserTalkingInVoiceConfMessage => handleUserTalkingInVoiceConfMessage(msg) + case msg: VoiceConfRecordingStartedMessage => handleVoiceConfRecordingStartedMessage(msg) case msg: UserJoining => handleUserJoin(msg) case msg: UserLeaving => handleUserLeft(msg) case msg: AssignPresenter => handleAssignPresenter(msg) @@ -119,7 +120,6 @@ class MeetingActor(val meetingID: String, val externalMeetingID: String, val mee case msg: IsWhiteboardEnabledRequest => handleIsWhiteboardEnabledRequest(msg) case msg: SetRecordingStatus => handleSetRecordingStatus(msg) case msg: GetRecordingStatus => handleGetRecordingStatus(msg) - case msg: VoiceRecording => handleVoiceRecording(msg) case msg: EndMeeting => handleEndMeeting(msg) case StopMeetingActor => //exit @@ -206,14 +206,12 @@ class MeetingActor(val meetingID: String, val externalMeetingID: String, val mee outGW.send(new DisconnectAllUsers(msg.meetingID)) } - private def handleVoiceRecording(msg: VoiceRecording) { + private def handleVoiceConfRecordingStartedMessage(msg: VoiceConfRecordingStartedMessage) { if (msg.recording) { outGW.send(new VoiceRecordingStarted(meetingID, - recorded, msg.recordingFile, - msg.timestamp, voiceBridge)) + recorded, msg.recordStream, msg.timestamp, voiceBridge)) } else { - outGW.send(new VoiceRecordingStopped(meetingID, recorded, - msg.recordingFile, msg.timestamp, voiceBridge)) + outGW.send(new VoiceRecordingStopped(meetingID, recorded, msg.recordStream, msg.timestamp, voiceBridge)) } } diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/Constants.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/Constants.scala index 867bec3a53af..0fedd00ed6b4 100755 --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/Constants.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/Constants.scala @@ -57,6 +57,8 @@ object Constants { val TALKING = "talking" val USER = "user" val MUTED = "muted" + val VOICE_CONF_ID = "voice_conf_id" + val VOICE_USER_ID = "voice_user_id" val VOICE_USER = "voice_user" val RECORDING_FILE = "recording_file" val ANNOTATION = "annotation" diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/InMessages.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/InMessages.scala index 6b93e92e356f..1778dc4efd4f 100755 --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/InMessages.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/InMessages.scala @@ -311,34 +311,21 @@ case class VoiceUserJoinedMessage( muted: Boolean, talking: Boolean) extends InMessage -case class VoiceUserJoined( - meetingID: String, - voiceUser: VoiceUser) extends InMessage - -case class VoiceUserLeft( - meetingID: String, - userId: String) extends InMessage - -case class VoiceUserLocked( - meetingID: String, - userId: String, - locked: Boolean) extends InMessage - -case class VoiceUserMuted( - meetingID: String, - userId: String, - muted: Boolean) extends InMessage - -case class VoiceUserTalking( - meetingID: String, - userId: String, - talking: Boolean) extends InMessage - -case class VoiceRecording( - meetingID: String, - recordingFile: String, - timestamp: String, - recording: Boolean) extends InMessage +case class UserJoinedVoiceConfMessage( + voiceConfId: String, voiceUserId: String, userId: String, callerIdName: String, + callerIdNum: String, muted: Boolean, talking: Boolean) + +case class UserLeftVoiceConfMessage(voiceConfId: String, voiceUserId: String) +case class UserLockedInVoiceConfMessage(voiceConfId: String, voiceUserId: String, locked: Boolean) +case class UserMutedInVoiceConfMessage(voiceConfId: String, voiceUserId: String, muted: Boolean) +case class UserTalkingInVoiceConfMessage(voiceConfId: String, voiceUserId: String, talking: Boolean) +case class VoiceConfRecordingStartedMessage(voiceConfId: String, recordStream: String, recording: Boolean, timestamp: String) +//case class VoiceUserJoined(meetingID: String, voiceUser: VoiceUser) extends InMessage +//case class VoiceUserLeft(meetingID: String, userId: String) extends InMessage +//case class VoiceUserLocked(meetingID: String, userId: String, locked: Boolean) extends InMessage +//case class VoiceUserMuted(meetingID: String, userId: String, muted: Boolean) extends InMessage +//case class VoiceUserTalking( meetingID: String, userId: String, talking: Boolean) extends InMessage +//case class VoiceRecording(meetingID: String, recordingFile: String, timestamp: String, recording: Boolean) extends InMessage // Whiteboard case class SendWhiteboardAnnotationRequest( diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/OutMessages.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/OutMessages.scala index de4be709e3d4..20c8bbd712bb 100755 --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/OutMessages.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/OutMessages.scala @@ -228,6 +228,8 @@ case class MuteVoiceUser( recorded: Boolean, requesterID: String, userId: String, + voiceConfId: String, + voiceUserId: String, mute: Boolean, version: String = Versions.V_0_0_1) extends IOutMessage @@ -250,6 +252,8 @@ case class EjectVoiceUser( recorded: Boolean, requesterID: String, userId: String, + voiceConfId: String, + voiceUserId: String, version: String = Versions.V_0_0_1) extends IOutMessage case class UserJoinedVoice( diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/ValueObjects.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/ValueObjects.scala index 82de5a8a5a93..a4e6b8dce3f3 100755 --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/ValueObjects.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/api/ValueObjects.scala @@ -71,7 +71,8 @@ case class UserVO( voiceUser: VoiceUser, listenOnly: Boolean) -case class VoiceUser(userId: String, +case class VoiceUser( + userId: String, webUserId: String, callerName: String, callerNum: String, diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala index 578f05f25ea4..00af261dfba0 100755 --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/users/UsersApp.scala @@ -59,7 +59,7 @@ trait UsersApp { outGW.send(new MeetingMuted(meetingID, recorded, meetingMuted)) usersWhoAreNotPresenter foreach { u => - outGW.send(new MuteVoiceUser(meetingID, recorded, msg.requesterID, u.userID, msg.mute)) + outGW.send(new MuteVoiceUser(meetingID, recorded, msg.requesterID, u.userID, voiceBridge, u.voiceUser.userId, msg.mute)) } } @@ -67,7 +67,7 @@ trait UsersApp { meetingMuted = msg.mute outGW.send(new MeetingMuted(meetingID, recorded, meetingMuted)) users.getUsers foreach { u => - outGW.send(new MuteVoiceUser(meetingID, recorded, msg.requesterID, u.userID, msg.mute)) + outGW.send(new MuteVoiceUser(meetingID, recorded, msg.requesterID, u.userID, voiceBridge, u.voiceUser.userId, msg.mute)) } } @@ -125,7 +125,7 @@ trait UsersApp { case Some(u) => { // println("Sending mute user request uid=[" + msg.userID + "] mute=[" + msg.mute + "]") log.info("Muting user: mid=[" + meetingID + "] uid=[" + u.userID + "]") - outGW.send(new MuteVoiceUser(meetingID, recorded, msg.requesterID, u.userID, msg.mute)) + outGW.send(new MuteVoiceUser(meetingID, recorded, msg.requesterID, u.userID, voiceBridge, u.voiceUser.userId, msg.mute)) } case None => { log.info("Could not find user to mute: mid=[" + meetingID + "] uid=[" + msg.userID + "]") @@ -140,7 +140,7 @@ trait UsersApp { case Some(u) => { if (u.voiceUser.joined) { log.info("Ejecting user from voice: mid=[" + meetingID + "] uid=[" + u.userID + "]") - outGW.send(new EjectVoiceUser(meetingID, recorded, msg.ejectedBy, u.userID)) + outGW.send(new EjectVoiceUser(meetingID, recorded, msg.ejectedBy, u.userID, voiceBridge, u.voiceUser.userId)) } } case None => // do nothing @@ -226,7 +226,7 @@ trait UsersApp { def handleEjectUserFromMeeting(msg: EjectUserFromMeeting) { users.getUser(msg.userId) foreach { user => if (user.voiceUser.joined) { - outGW.send(new EjectVoiceUser(meetingID, recorded, msg.ejectedBy, msg.userId)) + outGW.send(new EjectVoiceUser(meetingID, recorded, msg.ejectedBy, msg.userId, voiceBridge, user.voiceUser.userId)) } users.removeUser(msg.userId) @@ -326,49 +326,49 @@ trait UsersApp { permissions.lockOnJoin && !role.equals(Role.MODERATOR) } - def handleUserJoinedVoiceFromPhone(msg: VoiceUserJoined) = { - val user = users.getUserWithVoiceUserId(msg.voiceUser.userId) match { + def handleUserJoinedVoiceFromPhone(msg: UserJoinedVoiceConfMessage) = { + val user = users.getUserWithVoiceUserId(msg.voiceUserId) match { case Some(user) => { - log.info("Voice user=[" + msg.voiceUser.userId + "] is already in conf=[" + voiceBridge + "]. Must be duplicate message.") + log.info("Voice user=[" + msg.voiceUserId + "] is already in conf=[" + voiceBridge + "]. Must be duplicate message.") } case None => { // No current web user. This means that the user called in through // the phone. We need to generate a new user as we are not able // to match with a web user. val webUserId = users.generateWebUserId - val vu = new VoiceUser(msg.voiceUser.userId, webUserId, - msg.voiceUser.callerName, msg.voiceUser.callerNum, + val vu = new VoiceUser(msg.voiceUserId, webUserId, msg.callerIdName, msg.callerIdNum, true, false, false, false) val sessionId = "PHONE-" + webUserId; - val uvo = new UserVO(webUserId, webUserId, msg.voiceUser.callerName, + val uvo = new UserVO(webUserId, webUserId, msg.callerIdName, Role.VIEWER, raiseHand = false, presenter = false, hasStream = false, locked = getInitialLockStatus(Role.VIEWER), webcamStreams = new ListSet[String](), phoneUser = true, vu, listenOnly = false) users.addUser(uvo) - log.info("New user joined voice for user [" + uvo.name + "] userid=[" + msg.voiceUser.webUserId + "]") + log.info("New user joined voice for user [" + uvo.name + "] userid=[" + webUserId + "]") outGW.send(new UserJoined(meetingID, recorded, uvo, sessionId)) outGW.send(new UserJoinedVoice(meetingID, recorded, voiceBridge, uvo)) if (meetingMuted) - outGW.send(new MuteVoiceUser(meetingID, recorded, uvo.userID, uvo.userID, meetingMuted)) + outGW.send(new MuteVoiceUser(meetingID, recorded, uvo.userID, uvo.userID, voiceBridge, vu.userId, meetingMuted)) } } } - def handleVoiceUserJoined(msg: VoiceUserJoined) = { - val user = users.getUser(msg.voiceUser.webUserId) match { + def handleUserJoinedVoiceConfMessage(msg: UserJoinedVoiceConfMessage) = { + val user = users.getUser(msg.userId) match { case Some(user) => { - val nu = user.copy(voiceUser = msg.voiceUser) + val vu = new VoiceUser(msg.voiceUserId, msg.userId, msg.callerIdName, msg.callerIdNum, true, false, msg.muted, msg.talking) + val nu = user.copy(voiceUser = vu) users.addUser(nu) - log.info("Received user joined voice for user [" + nu.name + "] userid=[" + msg.voiceUser.webUserId + "]") + log.info("Received user joined voice for user [" + nu.name + "] userid=[" + msg.userId + "]") outGW.send(new UserJoinedVoice(meetingID, recorded, voiceBridge, nu)) if (meetingMuted) - outGW.send(new MuteVoiceUser(meetingID, recorded, nu.userID, nu.userID, meetingMuted)) + outGW.send(new MuteVoiceUser(meetingID, recorded, nu.userID, nu.userID, voiceBridge, nu.voiceUser.userId, meetingMuted)) } case None => { handleUserJoinedVoiceFromPhone(msg) @@ -376,28 +376,27 @@ trait UsersApp { } } - def handleVoiceUserLeft(msg: VoiceUserLeft) { - users.getUser(msg.userId) foreach { user => - val vu = new VoiceUser(user.userID, user.userID, user.name, user.name, - false, false, false, false) + def handleUserLeftVoiceConfMessage(msg: UserLeftVoiceConfMessage) { + users.getUserWithVoiceUserId(msg.voiceUserId) foreach { user => + val vu = new VoiceUser(user.userID, user.userID, user.name, user.name, false, false, false, false) val nu = user.copy(voiceUser = vu) users.addUser(nu) // println("Received voice user left =[" + user.name + "] wid=[" + msg.userId + "]" ) - log.info("Received user left voice for user [" + nu.name + "] userid=[" + msg.userId + "]") + log.info("Received user left voice for user [" + nu.name + "] userid=[" + msg.voiceUserId + "]") outGW.send(new UserLeftVoice(meetingID, recorded, voiceBridge, nu)) if (user.phoneUser) { if (users.hasUser(user.userID)) { val userLeaving = users.removeUser(user.userID) - userLeaving foreach (u => outGW.send(new UserLeft(msg.meetingID, recorded, u))) + userLeaving foreach (u => outGW.send(new UserLeft(meetingID, recorded, u))) } } } } - def handleVoiceUserMuted(msg: VoiceUserMuted) { - users.getUser(msg.userId) foreach { user => + def handleUserMutedInVoiceConfMessage(msg: UserMutedInVoiceConfMessage) { + users.getUserWithVoiceUserId(msg.voiceUserId) foreach { user => val talking: Boolean = if (msg.muted) false else user.voiceUser.talking val nv = user.voiceUser.copy(muted = msg.muted, talking = talking) val nu = user.copy(voiceUser = nv) @@ -407,8 +406,8 @@ trait UsersApp { } } - def handleVoiceUserTalking(msg: VoiceUserTalking) { - users.getUser(msg.userId) foreach { user => + def handleUserTalkingInVoiceConfMessage(msg: UserTalkingInVoiceConfMessage) { + users.getUserWithVoiceUserId(msg.voiceUserId) foreach { user => val nv = user.voiceUser.copy(talking = msg.talking) val nu = user.copy(voiceUser = nv) users.addUser(nu) diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/VoiceInGateway.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/VoiceInGateway.scala old mode 100644 new mode 100755 index f06efed41dcb..baa6e3ed374b --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/VoiceInGateway.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/apps/voice/VoiceInGateway.scala @@ -29,37 +29,34 @@ class VoiceInGateway(bbbGW: BigBlueButtonGateway) { bbbGW.accept(new EjectUserFromVoiceRequest(meetingID, userId, ejectedBy)) } - def voiceUserJoined(meetingId: String, userId: String, webUserId: String, - conference: String, callerIdNum: String, - callerIdName: String, - muted: Boolean, talking: Boolean) { + def voiceUserJoined(voiceConfId: String, voiceUserId: String, userId: String, callerIdName: String, + callerIdNum: String, muted: Boolean, talking: Boolean) { // println("VoiceInGateway: Got voiceUserJoined message for meeting [" + meetingId + "] user[" + callerIdName + "]") - val voiceUser = new VoiceUser(userId, webUserId, - callerIdName, callerIdNum, - true, false, muted, talking) - bbbGW.accept(new VoiceUserJoined(meetingId, voiceUser)) + val voiceUser = new VoiceUser(voiceUserId, userId, callerIdName, callerIdNum, true, false, muted, talking) + val msg = new UserJoinedVoiceConfMessage(voiceConfId, voiceUserId, userId, callerIdName, + callerIdNum, muted, talking) + + bbbGW.acceptUserJoinedVoiceConfMessage(msg) } - def voiceUserLeft(meetingId: String, userId: String) { + def voiceUserLeft(voiceConfId: String, voiceUserId: String) { // println("VoiceInGateway: Got voiceUserLeft message for meeting [" + meetingId + "] user[" + userId + "]") - bbbGW.accept(new VoiceUserLeft(meetingId, userId)) + bbbGW.acceptUserLeftVoiceConfMessage(new UserLeftVoiceConfMessage(voiceConfId, voiceUserId)) } - def voiceUserLocked(meetingId: String, userId: String, locked: Boolean) { - bbbGW.accept(new VoiceUserLocked(meetingId, userId, locked)) + def voiceUserLocked(voiceConfId: String, voiceUserId: String, locked: Boolean) { + bbbGW.acceptUserLockedInVoiceConfMessage(new UserLockedInVoiceConfMessage(voiceConfId, voiceUserId, locked)) } - def voiceUserMuted(meetingId: String, userId: String, muted: Boolean) { - bbbGW.accept(new VoiceUserMuted(meetingId, userId, muted)) + def voiceUserMuted(voiceConfId: String, voiceUserId: String, muted: Boolean) { + bbbGW.acceptUserMutedInVoiceConfMessage(new UserMutedInVoiceConfMessage(voiceConfId, voiceUserId, muted)) } - def voiceUserTalking(meetingId: String, userId: String, talking: Boolean) { - bbbGW.accept(new VoiceUserTalking(meetingId, userId, talking)) + def voiceUserTalking(voiceConfId: String, voiceUserId: String, talking: Boolean) { + bbbGW.acceptUserTalkingInVoiceConfMessage(new UserTalkingInVoiceConfMessage(voiceConfId, voiceUserId, talking)) } - def voiceRecording(meetingId: String, recordingFile: String, - timestamp: String, recording: java.lang.Boolean) { - bbbGW.accept(new VoiceRecording(meetingId, recordingFile, - timestamp, recording)) + def voiceRecording(voiceConfId: String, recordingFile: String, timestamp: String, recording: java.lang.Boolean) { + bbbGW.acceptVoiceConfRecordingStartedMessage(new VoiceConfRecordingStartedMessage(voiceConfId, recordingFile, recording, timestamp)) } } \ No newline at end of file diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/UsersEventRedisPublisher.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/UsersEventRedisPublisher.scala index 10dc6d70bd19..c6687bf951b4 100755 --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/UsersEventRedisPublisher.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/UsersEventRedisPublisher.scala @@ -7,6 +7,7 @@ import com.google.gson.Gson import org.bigbluebutton.common.messages.GetCurrentLayoutReplyMessage import org.bigbluebutton.common.messages.BroadcastLayoutMessage import org.bigbluebutton.common.messages.LockLayoutMessage +import org.bigbluebutton.common.messages.{ MuteUserInVoiceConfRequestMessage, EjectUserFromVoiceConfRequestMessage } class UsersEventRedisPublisher(service: MessageSender) extends OutMessageListener2 { @@ -178,13 +179,14 @@ class UsersEventRedisPublisher(service: MessageSender) extends OutMessageListene } private def handleMuteVoiceUser(msg: MuteVoiceUser) { - val json = UsersMessageToJsonConverter.muteVoiceUserToJson(msg) - service.send(MessagingConstants.FROM_USERS_CHANNEL, json) + val m = new MuteUserInVoiceConfRequestMessage(msg.meetingID, msg.voiceConfId, msg.voiceUserId, msg.mute) + service.send(MessagingConstants.TO_VOICE_CONF_SYSTEM_CHAN, m.toJson()) } private def handleEjectVoiceUser(msg: EjectVoiceUser) { - val json = UsersMessageToJsonConverter.ejectVoiceUserToJson(msg) - service.send(MessagingConstants.FROM_USERS_CHANNEL, json) + val m = new EjectUserFromVoiceConfRequestMessage(msg.meetingID, msg.voiceConfId, msg.voiceUserId) + service.send(MessagingConstants.TO_VOICE_CONF_SYSTEM_CHAN, m.toJson()) + } private def handleUserLeftVoice(msg: UserLeftVoice) { diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/UsersMessageToJsonConverter.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/UsersMessageToJsonConverter.scala index 046be6d67f73..dd97ded14b03 100755 --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/UsersMessageToJsonConverter.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/UsersMessageToJsonConverter.scala @@ -294,6 +294,8 @@ object UsersMessageToJsonConverter { payload.put(Constants.MUTE, msg.mute) payload.put(Constants.USER_ID, msg.userId) payload.put(Constants.REQUESTER_ID, msg.requesterID) + payload.put(Constants.VOICE_CONF_ID, msg.voiceConfId) + payload.put(Constants.VOICE_USER_ID, msg.voiceUserId) val header = Util.buildHeader(MessageNames.EJECT_VOICE_USER, msg.version, None) Util.buildJson(header, payload) @@ -305,6 +307,8 @@ object UsersMessageToJsonConverter { payload.put(Constants.RECORDED, msg.recorded) payload.put(Constants.USER_ID, msg.userId) payload.put(Constants.REQUESTER_ID, msg.requesterID) + payload.put(Constants.VOICE_CONF_ID, msg.voiceConfId) + payload.put(Constants.VOICE_USER_ID, msg.voiceUserId) val header = Util.buildHeader(MessageNames.EJECT_VOICE_USER, msg.version, None) Util.buildJson(header, payload) diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ChatEventRedisRecorder.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/ChatEventRedisRecorder.scala similarity index 92% rename from labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ChatEventRedisRecorder.scala rename to labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/ChatEventRedisRecorder.scala index 969f59eb3c5d..da50c4550149 100755 --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/ChatEventRedisRecorder.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/ChatEventRedisRecorder.scala @@ -1,4 +1,4 @@ -package org.bigbluebutton.core.pubsub.senders +package org.bigbluebutton.core.recorders import org.bigbluebutton.conference.service.recorder.RecorderApplication import org.bigbluebutton.core.api._ diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/PresentationEventRedisRecorder.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/PresentationEventRedisRecorder.scala similarity index 96% rename from labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/PresentationEventRedisRecorder.scala rename to labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/PresentationEventRedisRecorder.scala index 9d60a62a334b..12600928d8bc 100755 --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/PresentationEventRedisRecorder.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/PresentationEventRedisRecorder.scala @@ -1,4 +1,4 @@ -package org.bigbluebutton.core.pubsub.senders +package org.bigbluebutton.core.recorders import org.bigbluebutton.conference.service.recorder.RecorderApplication import org.bigbluebutton.core.api.OutMessageListener2 diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/UsersEventRedisRecorder.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/UsersEventRedisRecorder.scala similarity index 96% rename from labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/UsersEventRedisRecorder.scala rename to labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/UsersEventRedisRecorder.scala index 9a15792785d1..3d9e31d03859 100755 --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/UsersEventRedisRecorder.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/UsersEventRedisRecorder.scala @@ -1,4 +1,4 @@ -package org.bigbluebutton.core.pubsub.senders +package org.bigbluebutton.core.recorders import org.bigbluebutton.conference.service.recorder.RecorderApplication import org.bigbluebutton.core.api._ diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/WhiteboardEventRedisRecorder.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/WhiteboardEventRedisRecorder.scala similarity index 96% rename from labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/WhiteboardEventRedisRecorder.scala rename to labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/WhiteboardEventRedisRecorder.scala index 408f1efa3be2..9bad10a45bfc 100755 --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/pubsub/senders/WhiteboardEventRedisRecorder.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/core/recorders/WhiteboardEventRedisRecorder.scala @@ -1,4 +1,4 @@ -package org.bigbluebutton.core.pubsub.senders +package org.bigbluebutton.core.recorders import org.bigbluebutton.conference.service.recorder.RecorderApplication import org.bigbluebutton.core.api._ diff --git a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/AppsRedisSubscriberActor.scala b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/AppsRedisSubscriberActor.scala index 8f7887243a29..c7929f536cdf 100755 --- a/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/AppsRedisSubscriberActor.scala +++ b/labs/akka-bbb-apps/src/main/scala/org/bigbluebutton/endpoint/redis/AppsRedisSubscriberActor.scala @@ -13,7 +13,7 @@ import org.bigbluebutton.core.pubsub.receivers.RedisMessageReceiver object AppsRedisSubscriberActor extends SystemConfiguration { val channels = Seq("time") - val patterns = Seq("bigbluebutton:to-bbb-apps:*") + val patterns = Seq("bigbluebutton:to-bbb-apps:*", "bigbluebutton:from-voice-conf:*") def props(msgReceiver: RedisMessageReceiver): Props = Props(classOf[AppsRedisSubscriberActor], msgReceiver, diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/Constants.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/Constants.java new file mode 100755 index 000000000000..96e28ed3f2dd --- /dev/null +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/Constants.java @@ -0,0 +1,130 @@ +package org.bigbluebutton.freeswitch.pubsub.messages; + +public class Constants { + public static final String NAME = "name"; + public static final String HEADER = "header"; + public static final String PAYLOAD = "payload"; + public static final String MEETING_ID = "meeting_id"; + public static final String EXTERNAL_MEETING_ID = "external_meeting_id"; + public static final String TIMESTAMP = "timestamp"; + public static final String USER_ID = "userid"; + public static final String RECORDED = "recorded"; + public static final String MEETING_NAME = "meeting_name"; + public static final String MEETING_MUTED = "meetingMuted"; + public static final String VOICE_CONF = "voice_conf"; + public static final String DURATION = "duration"; + public static final String AUTH_TOKEN = "auth_token"; + public static final String ROLE = "role"; + public static final String EXT_USER_ID = "external_user_id"; + public static final String EXTERN_USERID = "extern_userid"; + public static final String REQUESTER_ID = "requester_id"; + public static final String REPLY_TO = "reply_to"; + public static final String LOWERED_BY = "lowered_by"; + public static final String STREAM = "stream"; + public static final String LOCKED = "locked"; + public static final String SETTINGS = "settings"; + public static final String LOCK = "lock"; + public static final String EXCEPT_USERS = "except_users"; + public static final String STATUS = "status"; + public static final String VALUE = "value"; + public static final String NEW_PRESENTER_ID = "new_presenter_id"; + public static final String NEW_PRESENTER_NAME = "new_presenter_name"; + public static final String ASSIGNED_BY = "assigned_by"; + public static final String RECORDING = "recording"; + public static final String AUTO_START_RECORDING = "auto_start_recording"; + public static final String ALLOW_START_STOP_RECORDING = "allow_start_stop_recording"; + public static final String LAYOUT_ID = "layout_id"; + public static final String LISTENONLY = "listenOnly"; + public static final String LISTEN_ONLY = "listen_only"; + public static final String POLL = "poll"; + public static final String POLL_ID = "poll_id"; + public static final String FORCE = "force"; + public static final String RESPONSE = "response"; + public static final String PRESENTATION_ID = "presentation_id"; + public static final String X_OFFSET = "x_offset"; + public static final String Y_OFFSET = "y_offset"; + public static final String WIDTH_RATIO = "width_ratio"; + public static final String HEIGHT_RATIO = "height_ratio"; + public static final String PAGE = "page"; + public static final String SHARE = "share"; + public static final String PRESENTATIONS = "presentations"; + public static final String MESSAGE_KEY = "message_key"; + public static final String CODE = "code"; + public static final String PRESENTATION_NAME = "presentation_name"; + public static final String NUM_PAGES = "num_pages"; + public static final String MAX_NUM_PAGES = "max_num_pages"; + public static final String PAGES_COMPLETED = "pages_completed"; + public static final String MUTE = "mute"; + public static final String CALLER_ID_NUM = "caller_id_num"; + public static final String CALLER_ID_NAME = "caller_id_name"; + public static final String CALLERNUM = "callernum"; + public static final String CALLERNAME = "callername"; + public static final String TALKING = "talking"; + public static final String USER = "user"; + public static final String MUTED = "muted"; + public static final String VOICE_USER = "voice_user"; + public static final String VOICEUSER = "voiceUser"; + public static final String RECORDING_FILE = "recording_file"; + public static final String ANNOTATION = "annotation"; + public static final String WHITEBOARD_ID = "whiteboard_id"; + public static final String ENABLE = "enable"; + public static final String PRESENTER = "presenter"; + public static final String USERS = "users"; + public static final String RAISE_HAND = "raise_hand"; + public static final String HAS_STREAM = "has_stream"; + public static final String WEBCAM_STREAM = "webcam_stream"; + public static final String PHONE_USER = "phone_user"; + public static final String PERMISSIONS = "permissions"; + public static final String VALID = "valid"; + public static final String CHAT_HISTORY = "chat_history"; + public static final String MESSAGE = "message"; + public static final String SET_BY_USER_ID = "set_by_user_id"; + public static final String POLLS = "polls"; + public static final String REASON = "reason"; + public static final String RESPONDER = "responder"; + public static final String PRESENTATION_INFO = "presentation_info"; + public static final String SHAPES = "shapes"; + public static final String SHAPE = "shape"; + public static final String SHAPE_ID = "shape_id"; + public static final String PRESENTATION = "presentation"; + public static final String ID = "id"; + public static final String CURRENT = "current"; + public static final String PAGES = "pages"; + public static final String WEB_USER_ID = "web_user_id"; + public static final String WEB_USERID = "web_userid"; + public static final String JOINED = "joined"; + public static final String X_PERCENT = "x_percent"; + public static final String Y_PERCENT = "y_percent"; + public static final String KEEP_ALIVE_ID = "keep_alive_id"; + public static final String INTERNAL_USER_ID = "internal_user_id"; + public static final String MODERATOR_PASS = "moderator_pass"; + public static final String VIEWER_PASS = "viewer_pass"; + public static final String CREATE_TIME = "create_time"; + public static final String CREATE_DATE = "create_date"; + public static final String PRESENTATION_BASE_URL = "presentation_base_url"; + public static final String DISABLE_CAMERA = "disable_camera"; + public static final String LOCK_ON_JOIN_CONFIGURABLE = "lock_on_join_configurable"; + public static final String DISABLE_MICROPHONE = "disable_microphone"; + public static final String DISABLE_PRIVATE_CHAT = "disable_private_chat"; + public static final String DISABLE_PUBLIC_CHAT = "disable_public_chat"; + public static final String LOCK_ON_JOIN = "lock_on_join"; + public static final String LOCKED_LAYOUT = "locked_layout"; + public static final String CHAT_TYPE = "chat_type"; + public static final String TO_USERNAME = "to_username"; + public static final String FROM_USERNAME = "from_username"; + public static final String FROM_USERID = "from_userid"; + public static final String FROM_TZ_OFFSET = "from_tz_offset"; + public static final String FROM_COLOR = "from_color"; + public static final String TO_USERID = "to_userid"; + public static final String FROM_TIME = "from_time"; + public static final String PERM_DISABLE_CAM = "disableCam"; + public static final String PERM_DISABLE_MIC = "disableMic"; + public static final String PERM_DISABLE_PRIVCHAT = "disablePrivChat"; + public static final String PERM_DISABLE_PUBCHAT = "disablePubChat"; + public static final String PERM_LOCKED_LAYOUT = "lockedLayout"; + public static final String PERM_LOCK_ON_JOIN = "lockOnJoin"; + public static final String PERM_LOCK_ON_JOIN_CONFIG = "lockOnJoinConfigurable"; + public static final String ENABLED = "enabled"; +} + + diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/EjectAllUsersFromVoiceConfRequestMessage.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/EjectAllUsersFromVoiceConfRequestMessage.java new file mode 100755 index 000000000000..100326ca17e4 --- /dev/null +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/EjectAllUsersFromVoiceConfRequestMessage.java @@ -0,0 +1,56 @@ +package org.bigbluebutton.freeswitch.pubsub.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class EjectAllUsersFromVoiceConfRequestMessage { + public static final String EJECT_ALL_VOICE_USERS_REQUEST = "eject_all_users_from_voice_conf_request_message"; + public static final String VERSION = "0.0.1"; + + public static final String MEETING_ID = "meeting_id"; + public static final String VOICE_CONF_ID = "voice_conf_id"; + + public final String meetingId; + public final String voiceConfId; + + public EjectAllUsersFromVoiceConfRequestMessage(String meetingId, String voiceConfId) { + this.meetingId = meetingId; + this.voiceConfId = voiceConfId; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(MEETING_ID, meetingId); + payload.put(VOICE_CONF_ID, voiceConfId); + + java.util.HashMap header = MessageBuilder.buildHeader(EJECT_ALL_VOICE_USERS_REQUEST, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static EjectAllUsersFromVoiceConfRequestMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (EJECT_ALL_VOICE_USERS_REQUEST.equals(messageName)) { + if (payload.has(MEETING_ID) + && payload.has(VOICE_CONF_ID)) { + String id = payload.get(MEETING_ID).getAsString(); + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + return new EjectAllUsersFromVoiceConfRequestMessage(id, voiceConfId); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/EjectUserFromVoiceConfRequestMessage.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/EjectUserFromVoiceConfRequestMessage.java new file mode 100755 index 000000000000..8b2db7d1dee2 --- /dev/null +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/EjectUserFromVoiceConfRequestMessage.java @@ -0,0 +1,62 @@ +package org.bigbluebutton.freeswitch.pubsub.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class EjectUserFromVoiceConfRequestMessage { + public static final String EJECT_VOICE_USER_REQUEST = "eject_user_from_voice_conf_request_message"; + public static final String VERSION = "0.0.1"; + + public static final String MEETING_ID = "meeting_id"; + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String VOICE_USER_ID = "voice_user_id"; + + public final String meetingId; + public final String voiceConfId; + public final String voiceUserId; + + public EjectUserFromVoiceConfRequestMessage(String meetingId, String voiceConfId, String voiceUserId) { + this.meetingId = meetingId; + this.voiceConfId = voiceConfId; + this.voiceUserId = voiceUserId; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(MEETING_ID, meetingId); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(VOICE_USER_ID, voiceUserId); + + java.util.HashMap header = MessageBuilder.buildHeader(EJECT_VOICE_USER_REQUEST, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static EjectUserFromVoiceConfRequestMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (EJECT_VOICE_USER_REQUEST.equals(messageName)) { + if (payload.has(MEETING_ID) + && payload.has(VOICE_CONF_ID) + && payload.has(VOICE_USER_ID)) { + String id = payload.get(MEETING_ID).getAsString(); + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String voiceUserId = payload.get(VOICE_USER_ID).getAsString(); + return new EjectUserFromVoiceConfRequestMessage(id, voiceConfId, voiceUserId); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/GetUsersFromVoiceConfRequestMessage.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/GetUsersFromVoiceConfRequestMessage.java new file mode 100755 index 000000000000..16dd72400b2e --- /dev/null +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/GetUsersFromVoiceConfRequestMessage.java @@ -0,0 +1,56 @@ +package org.bigbluebutton.freeswitch.pubsub.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class GetUsersFromVoiceConfRequestMessage { + public static final String GET_VOICE_USERS_REQUEST = "get_users_from_voice_conf_request_message"; + public static final String VERSION = "0.0.1"; + + public static final String MEETING_ID = "meeting_id"; + public static final String VOICE_CONF_ID = "voice_conf_id"; + + public final String meetingId; + public final String voiceConfId; + + public GetUsersFromVoiceConfRequestMessage(String meetingId, String voiceConfId) { + this.meetingId = meetingId; + this.voiceConfId = voiceConfId; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(MEETING_ID, meetingId); + payload.put(VOICE_CONF_ID, voiceConfId); + + java.util.HashMap header = MessageBuilder.buildHeader(GET_VOICE_USERS_REQUEST, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static GetUsersFromVoiceConfRequestMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (GET_VOICE_USERS_REQUEST.equals(messageName)) { + if (payload.has(MEETING_ID) + && payload.has(VOICE_CONF_ID)) { + String id = payload.get(MEETING_ID).getAsString(); + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + return new GetUsersFromVoiceConfRequestMessage(id, voiceConfId); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/MessageBuilder.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/MessageBuilder.java new file mode 100755 index 000000000000..0bd78cb3ca5a --- /dev/null +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/MessageBuilder.java @@ -0,0 +1,36 @@ +package org.bigbluebutton.freeswitch.pubsub.messages; + +import java.util.concurrent.TimeUnit; + +import com.google.gson.Gson; + +public class MessageBuilder { + public final static String VERSION = "version"; + + public static long generateTimestamp() { + return TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); + } + + public static java.util.HashMap buildHeader(String name, String version, String replyTo) { + java.util.HashMap header = new java.util.HashMap(); + header.put(Constants.NAME, name); + header.put(VERSION, version); + header.put(Constants.TIMESTAMP, generateTimestamp()); + if (replyTo != null && replyTo != "") + header.put(Constants.REPLY_TO, replyTo); + + return header; + } + + + public static String buildJson(java.util.HashMap header, + java.util.HashMap payload) { + + java.util.HashMap> message = new java.util.HashMap>(); + message.put(Constants.HEADER, header); + message.put(Constants.PAYLOAD, payload); + + Gson gson = new Gson(); + return gson.toJson(message); + } +} diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/MuteUserInVoiceConfRequestMessage.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/MuteUserInVoiceConfRequestMessage.java new file mode 100755 index 000000000000..2be732529bec --- /dev/null +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/MuteUserInVoiceConfRequestMessage.java @@ -0,0 +1,68 @@ +package org.bigbluebutton.freeswitch.pubsub.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class MuteUserInVoiceConfRequestMessage { + public static final String MUTE_VOICE_USER_REQUEST = "mute_user_in_voice_conf_request_message"; + public static final String VERSION = "0.0.1"; + + public static final String MEETING_ID = "meeting_id"; + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String VOICE_USER_ID = "voice_user_id"; + public static final String MUTE = "mute"; + + public final String meetingId; + public final String voiceConfId; + public final String voiceUserId; + public final Boolean mute; + + public MuteUserInVoiceConfRequestMessage(String meetingId, String voiceConfId, String voiceUserId, Boolean mute) { + this.meetingId = meetingId; + this.voiceConfId = voiceConfId; + this.voiceUserId = voiceUserId; + this.mute = mute; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(MEETING_ID, meetingId); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(VOICE_USER_ID, voiceUserId); + payload.put(MUTE, mute); + + java.util.HashMap header = MessageBuilder.buildHeader(MUTE_VOICE_USER_REQUEST, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static MuteUserInVoiceConfRequestMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (MUTE_VOICE_USER_REQUEST.equals(messageName)) { + if (payload.has(MEETING_ID) + && payload.has(VOICE_CONF_ID) + && payload.has(VOICE_USER_ID) + && payload.has(MUTE)) { + String id = payload.get(MEETING_ID).getAsString(); + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String voiceUserId = payload.get(VOICE_USER_ID).getAsString(); + Boolean mute = payload.get(MUTE).getAsBoolean(); + return new MuteUserInVoiceConfRequestMessage(id, voiceConfId, voiceUserId, mute); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/RecordVoiceConfRequestMessage.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/RecordVoiceConfRequestMessage.java new file mode 100755 index 000000000000..0e49c23c8957 --- /dev/null +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/RecordVoiceConfRequestMessage.java @@ -0,0 +1,62 @@ +package org.bigbluebutton.freeswitch.pubsub.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class RecordVoiceConfRequestMessage { + public static final String RECORD_VOICE_CONF_REQUEST = "record_voice_conf_request_message"; + public static final String VERSION = "0.0.1"; + + public static final String MEETING_ID = "meeting_id"; + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String RECORD = "record"; + + public final String meetingId; + public final String voiceConfId; + public final Boolean record; + + public RecordVoiceConfRequestMessage(String meetingId, String voiceConfId, Boolean record) { + this.meetingId = meetingId; + this.voiceConfId = voiceConfId; + this.record = record; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(MEETING_ID, meetingId); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(RECORD, record); + + java.util.HashMap header = MessageBuilder.buildHeader(RECORD_VOICE_CONF_REQUEST, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static RecordVoiceConfRequestMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (RECORD_VOICE_CONF_REQUEST.equals(messageName)) { + if (payload.has(MEETING_ID) + && payload.has(VOICE_CONF_ID) + && payload.has(RECORD)) { + String id = payload.get(MEETING_ID).getAsString(); + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + Boolean record = payload.get(RECORD).getAsBoolean(); + return new RecordVoiceConfRequestMessage(id, voiceConfId, record); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/StartRecordingVoiceConfRequestMessage.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/StartRecordingVoiceConfRequestMessage.java new file mode 100755 index 000000000000..b3ef7ad6c503 --- /dev/null +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/StartRecordingVoiceConfRequestMessage.java @@ -0,0 +1,56 @@ +package org.bigbluebutton.freeswitch.pubsub.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class StartRecordingVoiceConfRequestMessage { + public static final String START_RECORD_VOICE_CONF_REQUEST = "start_recording__voice_conf_request_message"; + public static final String VERSION = "0.0.1"; + + public static final String MEETING_ID = "meeting_id"; + public static final String VOICE_CONF_ID = "voice_conf_id"; + + public final String meetingId; + public final String voiceConfId; + + public StartRecordingVoiceConfRequestMessage(String meetingId, String voiceConfId) { + this.meetingId = meetingId; + this.voiceConfId = voiceConfId; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(MEETING_ID, meetingId); + payload.put(VOICE_CONF_ID, voiceConfId); + + java.util.HashMap header = MessageBuilder.buildHeader(START_RECORD_VOICE_CONF_REQUEST, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static StartRecordingVoiceConfRequestMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (START_RECORD_VOICE_CONF_REQUEST.equals(messageName)) { + if (payload.has(MEETING_ID) + && payload.has(VOICE_CONF_ID)) { + String id = payload.get(MEETING_ID).getAsString(); + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + return new StartRecordingVoiceConfRequestMessage(id, voiceConfId); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/StopRecordingVoiceConfRequestMessage.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/StopRecordingVoiceConfRequestMessage.java new file mode 100755 index 000000000000..3cf464a210a8 --- /dev/null +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/StopRecordingVoiceConfRequestMessage.java @@ -0,0 +1,62 @@ +package org.bigbluebutton.freeswitch.pubsub.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class StopRecordingVoiceConfRequestMessage { + public static final String RECORD_VOICE_CONF_REQUEST = "stop_recording_voice_conf_request_message"; + public static final String VERSION = "0.0.1"; + + public static final String MEETING_ID = "meeting_id"; + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String RECORD_STREAM = "record_stream"; + + public final String meetingId; + public final String voiceConfId; + public final String recordStream; + + public StopRecordingVoiceConfRequestMessage(String meetingId, String voiceConfId, String recordStream) { + this.meetingId = meetingId; + this.voiceConfId = voiceConfId; + this.recordStream = recordStream; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(MEETING_ID, meetingId); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(RECORD_STREAM, recordStream); + + java.util.HashMap header = MessageBuilder.buildHeader(RECORD_VOICE_CONF_REQUEST, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static StopRecordingVoiceConfRequestMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (RECORD_VOICE_CONF_REQUEST.equals(messageName)) { + if (payload.has(MEETING_ID) + && payload.has(VOICE_CONF_ID) + && payload.has(RECORD_STREAM)) { + String id = payload.get(MEETING_ID).getAsString(); + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String recordStream = payload.get(RECORD_STREAM).getAsString(); + return new StopRecordingVoiceConfRequestMessage(id, voiceConfId, recordStream); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/UserJoinedVoiceConfMessage.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/UserJoinedVoiceConfMessage.java new file mode 100755 index 000000000000..964b0762cd57 --- /dev/null +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/UserJoinedVoiceConfMessage.java @@ -0,0 +1,87 @@ +package org.bigbluebutton.freeswitch.pubsub.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class UserJoinedVoiceConfMessage { + public static final String USER_JOINED_VOICE_CONF = "user_joined_voice_conf_message"; + public static final String VERSION = "0.0.1"; + + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String VOICE_USER_ID = "voice_user_id"; + public static final String USER_ID = "user_id"; + public static final String CALLER_ID_NAME = "caller_id_name"; + public static final String CALLER_ID_NUM = "caller_id_num"; + public static final String MUTED = "muted"; + public static final String TALKING = "talking"; + + public final String voiceConfId; + public final String voiceUserId; + public final String userId; + public final String callerIdName; + public final String callerIdNum; + public final Boolean muted; + public final Boolean talking; + + public UserJoinedVoiceConfMessage(String voiceConfId, String voiceUserId, String userId, + String callerIdName, String callerIdNum, Boolean muted, Boolean talking) { + this.voiceConfId = voiceConfId; + this.voiceUserId = voiceUserId; + this.userId = userId; + this.callerIdName = callerIdName; + this.callerIdNum = callerIdNum; + this.muted = muted; + this.talking = talking; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(VOICE_USER_ID, voiceUserId); + payload.put(USER_ID, userId); + payload.put(CALLER_ID_NAME, callerIdName); + payload.put(CALLER_ID_NUM, callerIdNum); + payload.put(MUTED, muted); + payload.put(TALKING, talking); + + java.util.HashMap header = MessageBuilder.buildHeader(USER_JOINED_VOICE_CONF, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static UserJoinedVoiceConfMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (USER_JOINED_VOICE_CONF.equals(messageName)) { + if (payload.has(VOICE_CONF_ID) + && payload.has(VOICE_USER_ID) + && payload.has(USER_ID) + && payload.has(CALLER_ID_NAME) + && payload.has(CALLER_ID_NUM) + && payload.has(MUTED) + && payload.has(TALKING)) { + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String voiceUserId = payload.get(VOICE_USER_ID).getAsString(); + String userId = payload.get(USER_ID).getAsString(); + String callerIdName = payload.get(CALLER_ID_NAME).getAsString(); + String callerIdNum = payload.get(CALLER_ID_NUM).getAsString(); + Boolean muted = payload.get(MUTED).getAsBoolean(); + Boolean talking = payload.get(TALKING).getAsBoolean(); + return new UserJoinedVoiceConfMessage(voiceConfId, voiceUserId, userId, callerIdName, callerIdNum, muted, talking); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/UserLeftVoiceConfMessage.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/UserLeftVoiceConfMessage.java new file mode 100755 index 000000000000..cdf1eb356849 --- /dev/null +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/UserLeftVoiceConfMessage.java @@ -0,0 +1,56 @@ +package org.bigbluebutton.freeswitch.pubsub.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class UserLeftVoiceConfMessage { + public static final String USER_LEFT_VOICE_CONF = "user_left_voice_conf_message"; + public static final String VERSION = "0.0.1"; + + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String VOICE_USER_ID = "voice_user_id"; + + public final String voiceConfId; + public final String voiceUserId; + + public UserLeftVoiceConfMessage(String voiceConfId, String voiceUserId) { + this.voiceConfId = voiceConfId; + this.voiceUserId = voiceUserId; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(VOICE_USER_ID, voiceUserId); + + java.util.HashMap header = MessageBuilder.buildHeader(USER_LEFT_VOICE_CONF, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static UserLeftVoiceConfMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (USER_LEFT_VOICE_CONF.equals(messageName)) { + if (payload.has(VOICE_CONF_ID) + && payload.has(VOICE_USER_ID)) { + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String voiceUserId = payload.get(VOICE_USER_ID).getAsString(); + return new UserLeftVoiceConfMessage(voiceConfId, voiceUserId); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/UserLockedInVoiceConfMessage.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/UserLockedInVoiceConfMessage.java new file mode 100755 index 000000000000..ef8d356956ac --- /dev/null +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/UserLockedInVoiceConfMessage.java @@ -0,0 +1,62 @@ +package org.bigbluebutton.freeswitch.pubsub.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class UserLockedInVoiceConfMessage { + public static final String USER_LOCKED_IN_VOICE_CONF = "user_locked_in_voice_conf_message"; + public static final String VERSION = "0.0.1"; + + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String VOICE_USER_ID = "voice_user_id"; + public static final String LOCKED = "locked"; + + public final String voiceConfId; + public final String voiceUserId; + public final Boolean locked; + + public UserLockedInVoiceConfMessage(String voiceConfId, String voiceUserId, Boolean locked) { + this.voiceConfId = voiceConfId; + this.voiceUserId = voiceUserId; + this.locked = locked; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(VOICE_USER_ID, voiceUserId); + payload.put(LOCKED, locked); + + java.util.HashMap header = MessageBuilder.buildHeader(USER_LOCKED_IN_VOICE_CONF, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static UserLockedInVoiceConfMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (USER_LOCKED_IN_VOICE_CONF.equals(messageName)) { + if (payload.has(VOICE_CONF_ID) + && payload.has(VOICE_USER_ID) + && payload.has(LOCKED)) { + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String voiceUserId = payload.get(VOICE_USER_ID).getAsString(); + Boolean locked = payload.get(LOCKED).getAsBoolean(); + return new UserLockedInVoiceConfMessage(voiceConfId, voiceUserId, locked); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/UserMutedInVoiceConfMessage.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/UserMutedInVoiceConfMessage.java new file mode 100755 index 000000000000..50b450baf37c --- /dev/null +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/UserMutedInVoiceConfMessage.java @@ -0,0 +1,62 @@ +package org.bigbluebutton.freeswitch.pubsub.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class UserMutedInVoiceConfMessage { + public static final String USER_MUTED_IN_VOICE_CONF = "user_muted_in_voice_conf_message"; + public static final String VERSION = "0.0.1"; + + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String VOICE_USER_ID = "voice_user_id"; + public static final String MUTED = "muted"; + + public final String voiceConfId; + public final String voiceUserId; + public final Boolean muted; + + public UserMutedInVoiceConfMessage(String voiceConfId, String voiceUserId, Boolean muted) { + this.voiceConfId = voiceConfId; + this.voiceUserId = voiceUserId; + this.muted = muted; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(VOICE_USER_ID, voiceUserId); + payload.put(MUTED, muted); + + java.util.HashMap header = MessageBuilder.buildHeader(USER_MUTED_IN_VOICE_CONF, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static UserMutedInVoiceConfMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (USER_MUTED_IN_VOICE_CONF.equals(messageName)) { + if (payload.has(VOICE_CONF_ID) + && payload.has(VOICE_USER_ID) + && payload.has(MUTED)) { + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String voiceUserId = payload.get(VOICE_USER_ID).getAsString(); + Boolean muted = payload.get(MUTED).getAsBoolean(); + return new UserMutedInVoiceConfMessage(voiceConfId, voiceUserId, muted); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/UserTalkingInVoiceConfMessage.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/UserTalkingInVoiceConfMessage.java new file mode 100755 index 000000000000..18bd6f2d361e --- /dev/null +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/UserTalkingInVoiceConfMessage.java @@ -0,0 +1,62 @@ +package org.bigbluebutton.freeswitch.pubsub.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class UserTalkingInVoiceConfMessage { + public static final String USER_TALKING_IN_VOICE_CONF = "user_talking_in_voice_conf_message"; + public static final String VERSION = "0.0.1"; + + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String VOICE_USER_ID = "voice_user_id"; + public static final String TALKING = "talking"; + + public final String voiceConfId; + public final String voiceUserId; + public final Boolean talking; + + public UserTalkingInVoiceConfMessage(String voiceConfId, String voiceUserId, Boolean talking) { + this.voiceConfId = voiceConfId; + this.voiceUserId = voiceUserId; + this.talking = talking; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(VOICE_USER_ID, voiceUserId); + payload.put(TALKING, talking); + + java.util.HashMap header = MessageBuilder.buildHeader(USER_TALKING_IN_VOICE_CONF, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static UserTalkingInVoiceConfMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (USER_TALKING_IN_VOICE_CONF.equals(messageName)) { + if (payload.has(VOICE_CONF_ID) + && payload.has(VOICE_USER_ID) + && payload.has(TALKING)) { + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String voiceUserId = payload.get(VOICE_USER_ID).getAsString(); + Boolean talking = payload.get(TALKING).getAsBoolean(); + return new UserTalkingInVoiceConfMessage(voiceConfId, voiceUserId, talking); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/VoiceConfRecordingStartedMessage.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/VoiceConfRecordingStartedMessage.java new file mode 100755 index 000000000000..522e6ec3af90 --- /dev/null +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/messages/VoiceConfRecordingStartedMessage.java @@ -0,0 +1,69 @@ +package org.bigbluebutton.freeswitch.pubsub.messages; + +import java.util.HashMap; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + + +public class VoiceConfRecordingStartedMessage { + public static final String VOICE_CONF_RECORDING_STARTED = "voice_conf_recording_started_message"; + public static final String VERSION = "0.0.1"; + + public static final String VOICE_CONF_ID = "voice_conf_id"; + public static final String RECORD_STREAM = "record_stream"; + public static final String RECORDING = "recording"; + public static final String TIMESTAMP = "timestamp"; + + public final String voiceConfId; + public final String recordStream; + public final Boolean recording; + public final String timestamp; + + public VoiceConfRecordingStartedMessage(String voiceConfId, + String recordStream, Boolean recording, String timestamp) { + this.voiceConfId = voiceConfId; + this.recordStream = recordStream; + this.recording = recording; + this.timestamp = timestamp; + } + + public String toJson() { + HashMap payload = new HashMap(); + payload.put(VOICE_CONF_ID, voiceConfId); + payload.put(RECORD_STREAM, recordStream); + payload.put(RECORDING, recording); + payload.put(TIMESTAMP, timestamp); + + java.util.HashMap header = MessageBuilder.buildHeader(VOICE_CONF_RECORDING_STARTED, VERSION, null); + + return MessageBuilder.buildJson(header, payload); + } + + public static VoiceConfRecordingStartedMessage fromJson(String message) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + JsonObject payload = (JsonObject) obj.get("payload"); + + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + if (VOICE_CONF_RECORDING_STARTED.equals(messageName)) { + if (payload.has(VOICE_CONF_ID) + && payload.has(RECORD_STREAM) + && payload.has(RECORDING) + && payload.has(TIMESTAMP)) { + String voiceConfId = payload.get(VOICE_CONF_ID).getAsString(); + String recordStream = payload.get(RECORD_STREAM).getAsString(); + Boolean recording = payload.get(RECORDING).getAsBoolean(); + String timestamp = payload.get(TIMESTAMP).getAsString(); + return new VoiceConfRecordingStartedMessage(voiceConfId, recordStream, recording, timestamp); + } + } + } + } + return null; + + } +} diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/receivers/RedisMessageReceiver.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/receivers/RedisMessageReceiver.java index cb15361c821c..e89f2dece275 100755 --- a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/receivers/RedisMessageReceiver.java +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/pubsub/receivers/RedisMessageReceiver.java @@ -1,8 +1,20 @@ package org.bigbluebutton.freeswitch.pubsub.receivers; +import org.bigbluebutton.freeswitch.pubsub.messages.EjectAllUsersFromVoiceConfRequestMessage; +import org.bigbluebutton.freeswitch.pubsub.messages.EjectUserFromVoiceConfRequestMessage; +import org.bigbluebutton.freeswitch.pubsub.messages.GetUsersFromVoiceConfRequestMessage; +import org.bigbluebutton.freeswitch.pubsub.messages.MuteUserInVoiceConfRequestMessage; +import org.bigbluebutton.freeswitch.pubsub.messages.RecordVoiceConfRequestMessage; import org.bigbluebutton.freeswitch.voice.freeswitch.FreeswitchApplication; +import com.google.gson.JsonObject; +import com.google.gson.JsonParser; + public class RedisMessageReceiver { + + public static final String TO_VOICE_CONF_CHANNEL = "bigbluebutton:to-voice-conf"; + public static final String TO_VOICE_CONF_PATTERN = TO_VOICE_CONF_CHANNEL + ":*"; + public static final String TO_VOICE_CONF_SYSTEM_CHAN = TO_VOICE_CONF_CHANNEL + ":system"; private final FreeswitchApplication fsApp; @@ -11,6 +23,55 @@ public RedisMessageReceiver(FreeswitchApplication fsApp) { } public void handleMessage(String pattern, String channel, String message) { + if (channel.equalsIgnoreCase(TO_VOICE_CONF_SYSTEM_CHAN)) { + JsonParser parser = new JsonParser(); + JsonObject obj = (JsonObject) parser.parse(message); + + if (obj.has("header") && obj.has("payload")) { + JsonObject header = (JsonObject) obj.get("header"); + if (header.has("name")) { + String messageName = header.get("name").getAsString(); + switch (messageName) { + case EjectAllUsersFromVoiceConfRequestMessage.EJECT_ALL_VOICE_USERS_REQUEST: + processEjectAllVoiceUsersRequestMessage(message); + break; + case EjectUserFromVoiceConfRequestMessage.EJECT_VOICE_USER_REQUEST: + processEjectVoiceUserRequestMessage(message); + break; + case GetUsersFromVoiceConfRequestMessage.GET_VOICE_USERS_REQUEST: + processGetVoiceUsersRequestMessage(message); + break; + case MuteUserInVoiceConfRequestMessage.MUTE_VOICE_USER_REQUEST: + processMuteVoiceUserRequestMessage(message); + break; + case RecordVoiceConfRequestMessage.RECORD_VOICE_CONF_REQUEST: + processRecordVoiceConfRequestMessage(message); + break; + } + } + } + } + } + + private void processEjectAllVoiceUsersRequestMessage(String json) { + EjectAllUsersFromVoiceConfRequestMessage msg = EjectAllUsersFromVoiceConfRequestMessage.fromJson(json); + fsApp.ejectAll(msg.voiceConfId); + } + + private void processEjectVoiceUserRequestMessage(String json) { + EjectUserFromVoiceConfRequestMessage msg = EjectUserFromVoiceConfRequestMessage.fromJson(json); + } + + private void processGetVoiceUsersRequestMessage(String json) { + GetUsersFromVoiceConfRequestMessage msg = GetUsersFromVoiceConfRequestMessage.fromJson(json); + } + + private void processMuteVoiceUserRequestMessage(String json) { + MuteUserInVoiceConfRequestMessage msg = MuteUserInVoiceConfRequestMessage.fromJson(json); + } + + private void processRecordVoiceConfRequestMessage(String json) { + RecordVoiceConfRequestMessage msg = RecordVoiceConfRequestMessage.fromJson(json); } } diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/FreeswitchConferenceEventListener.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/FreeswitchConferenceEventListener.java index 638770574c6c..69326c4956ad 100755 --- a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/FreeswitchConferenceEventListener.java +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/FreeswitchConferenceEventListener.java @@ -60,26 +60,25 @@ public void run() { if (event instanceof VoiceUserJoinedEvent) { System.out.println("************** FreeswitchConferenceEventListener received voiceUserJoined "); VoiceUserJoinedEvent evt = (VoiceUserJoinedEvent) event; - vcs.voiceUserJoined(evt.getVoiceUserId(), evt.getUserId(), evt.getRoom(), - evt.getCallerIdNum(), evt.getCallerIdName(), - evt.getMuted(), evt.getSpeaking()); - } else if (event instanceof VoiceUserLeftEvent) { - System.out.println("************** FreeswitchConferenceEventListener received VoiceUserLeftEvent "); - VoiceUserLeftEvent evt = (VoiceUserLeftEvent) event; - vcs.voiceUserLeft(evt.getUserId(), evt.getRoom()); - } else if (event instanceof VoiceUserMutedEvent) { - System.out.println("************** FreeswitchConferenceEventListener VoiceUserMutedEvent "); - VoiceUserMutedEvent evt = (VoiceUserMutedEvent) event; - vcs.voiceUserMuted(evt.getUserId(), evt.getRoom(), evt.isMuted()); - } else if (event instanceof VoiceUserTalkingEvent) { - System.out.println("************** FreeswitchConferenceEventListener VoiceUserTalkingEvent "); - VoiceUserTalkingEvent evt = (VoiceUserTalkingEvent) event; - vcs.voiceUserTalking(evt.getUserId(), evt.getRoom(), evt.isTalking()); - } else if (event instanceof VoiceStartRecordingEvent) { - VoiceStartRecordingEvent evt = (VoiceStartRecordingEvent) event; - System.out.println("************** FreeswitchConferenceEventListener VoiceStartRecordingEvent recording=[" + evt.startRecord() + "]"); - vcs.voiceStartedRecording(evt.getRoom(), evt.getRecordingFilename(), evt.getTimestamp(), evt.startRecord()); - } + vcs.userJoinedVoiceConf(evt.getRoom(), evt.getVoiceUserId(), evt.getUserId(), evt.getCallerIdName(), + evt.getCallerIdNum(), evt.getMuted(), evt.getSpeaking()); + } else if (event instanceof VoiceUserLeftEvent) { + System.out.println("************** FreeswitchConferenceEventListener received VoiceUserLeftEvent "); + VoiceUserLeftEvent evt = (VoiceUserLeftEvent) event; + vcs.userLeftVoiceConf(evt.getRoom(), evt.getUserId()); + } else if (event instanceof VoiceUserMutedEvent) { + System.out.println("************** FreeswitchConferenceEventListener VoiceUserMutedEvent "); + VoiceUserMutedEvent evt = (VoiceUserMutedEvent) event; + vcs.userMutedInVoiceConf(evt.getRoom(), evt.getUserId(), evt.isMuted()); + } else if (event instanceof VoiceUserTalkingEvent) { + System.out.println("************** FreeswitchConferenceEventListener VoiceUserTalkingEvent "); + VoiceUserTalkingEvent evt = (VoiceUserTalkingEvent) event; + vcs.userTalkingInVoiceConf(evt.getRoom(), evt.getUserId(), evt.isTalking()); + } else if (event instanceof VoiceStartRecordingEvent) { + VoiceStartRecordingEvent evt = (VoiceStartRecordingEvent) event; + System.out.println("************** FreeswitchConferenceEventListener VoiceStartRecordingEvent recording=[" + evt.startRecord() + "]"); + vcs.voiceConfRecordingStarted(evt.getRoom(), evt.getRecordingFilename(), evt.startRecord(), evt.getTimestamp()); + } } }; diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/IVoiceConferenceService.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/IVoiceConferenceService.java index d9391a0df1e9..6bf57784fff2 100755 --- a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/IVoiceConferenceService.java +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/IVoiceConferenceService.java @@ -1,13 +1,12 @@ package org.bigbluebutton.freeswitch.voice; public interface IVoiceConferenceService { - void voiceUserJoined(String userId, String webUserId, String conference, - String callerIdNum, String callerIdName, - Boolean muted, Boolean speaking); - void voiceUserLeft(String meetingId, String userId); - void voiceUserLocked(String meetingId, String userId, Boolean locked); - void voiceUserMuted(String meetingId, String userId, Boolean muted); - void voiceUserTalking(String meetingId, String userId, Boolean talking); - void voiceStartedRecording(String conference, String recordingFile, - String timestamp, Boolean recording); + void voiceConfRecordingStarted(String voiceConfId, String recordStream, Boolean recording, String timestamp); + void userJoinedVoiceConf(String voiceConfId, String voiceUserId, String userId, String callerIdName, + String callerIdNum, Boolean muted, Boolean speaking); + void userLeftVoiceConf(String voiceConfId, String voiceUserId); + void userLockedInVoiceConf(String voiceConfId, String voiceUserId, Boolean locked); + void userMutedInVoiceConf(String voiceConfId, String voiceUserId, Boolean muted); + void userTalkingInVoiceConf(String voiceConfId, String voiceUserId, Boolean talking); + } diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/EjectParticipantCommand.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/EjectUserCommand.java similarity index 84% rename from labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/EjectParticipantCommand.java rename to labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/EjectUserCommand.java index c0b6784d8fda..3c29e2b63cb3 100755 --- a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/EjectParticipantCommand.java +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/EjectUserCommand.java @@ -18,11 +18,11 @@ */ package org.bigbluebutton.freeswitch.voice.commands; -public class EjectParticipantCommand extends ConferenceCommand { +public class EjectUserCommand extends ConferenceCommand { private final Integer participantId; - public EjectParticipantCommand(String room, Integer requesterId, Integer participantId) { + public EjectUserCommand(String room, Integer requesterId, Integer participantId) { super(room, requesterId); this.participantId = participantId; } diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/GetParticipantsCommand.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/GetUsersCommand.java similarity index 85% rename from labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/GetParticipantsCommand.java rename to labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/GetUsersCommand.java index 2d4ddd704ff7..13d21a4fb01e 100755 --- a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/GetParticipantsCommand.java +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/GetUsersCommand.java @@ -18,9 +18,9 @@ */ package org.bigbluebutton.freeswitch.voice.commands; -public class GetParticipantsCommand extends ConferenceCommand { +public class GetUsersCommand extends ConferenceCommand { - public GetParticipantsCommand(String room, Integer requesterId) { + public GetUsersCommand(String room, Integer requesterId) { super(room, requesterId); } diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/MuteParticipantCommand.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/MuteUserCommand.java similarity index 84% rename from labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/MuteParticipantCommand.java rename to labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/MuteUserCommand.java index bfa54b092fdf..62d2ece84c67 100755 --- a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/MuteParticipantCommand.java +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/MuteUserCommand.java @@ -18,12 +18,12 @@ */ package org.bigbluebutton.freeswitch.voice.commands; -public class MuteParticipantCommand extends ConferenceCommand { +public class MuteUserCommand extends ConferenceCommand { private final Integer participantId; private final boolean mute; - public MuteParticipantCommand(String room, Integer requesterId, Integer participantId, boolean mute) { + public MuteUserCommand(String room, Integer requesterId, Integer participantId, boolean mute) { super(room, requesterId); this.participantId = participantId; this.mute = mute; diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/RecordCommand.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/RecordCommand.java new file mode 100755 index 000000000000..bb60598dae09 --- /dev/null +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/commands/RecordCommand.java @@ -0,0 +1,27 @@ +/** +* BigBlueButton open source conferencing system - http://www.bigbluebutton.org/ +* +* Copyright (c) 2012 BigBlueButton Inc. and by respective authors (see below). +* +* This program is free software; you can redistribute it and/or modify it under the +* terms of the GNU Lesser General Public License as published by the Free Software +* Foundation; either version 3.0 of the License, or (at your option) any later +* version. +* +* BigBlueButton is distributed in the hope that it will be useful, but WITHOUT ANY +* WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A +* PARTICULAR PURPOSE. See the GNU Lesser General Public License for more details. +* +* You should have received a copy of the GNU Lesser General Public License along +* with BigBlueButton; if not, see . +* +*/ +package org.bigbluebutton.freeswitch.voice.commands; + +public class RecordCommand extends ConferenceCommand { + + public RecordCommand(String room, Integer requesterId) { + super(room, requesterId); + } + +} diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/ConnectionManager.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/ConnectionManager.java index 8d6662d8faad..517fb257f72e 100755 --- a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/ConnectionManager.java +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/ConnectionManager.java @@ -26,9 +26,9 @@ import org.bigbluebutton.freeswitch.voice.events.ConferenceEventListener; import org.bigbluebutton.freeswitch.voice.freeswitch.actions.BroadcastConferenceCommand; import org.bigbluebutton.freeswitch.voice.freeswitch.actions.EjectAllUsersCommand; -import org.bigbluebutton.freeswitch.voice.freeswitch.actions.EjectParticipantCommand; -import org.bigbluebutton.freeswitch.voice.freeswitch.actions.MuteParticipantCommand; -import org.bigbluebutton.freeswitch.voice.freeswitch.actions.PopulateRoomCommand; +import org.bigbluebutton.freeswitch.voice.freeswitch.actions.EjectUserCommand; +import org.bigbluebutton.freeswitch.voice.freeswitch.actions.MuteUserCommand; +import org.bigbluebutton.freeswitch.voice.freeswitch.actions.GetAllUsersCommand; import org.bigbluebutton.freeswitch.voice.freeswitch.actions.RecordConferenceCommand; import org.freeswitch.esl.client.inbound.Client; import org.freeswitch.esl.client.inbound.InboundConnectionFailure; @@ -106,7 +106,7 @@ public void broadcast(BroadcastConferenceCommand rcc) { } } - public void getUsers(PopulateRoomCommand prc) { + public void getUsers(GetAllUsersCommand prc) { Client c = manager.getESLClient(); if (c.canSend()) { EslMessage response = c.sendSyncApiCommand(prc.getCommand(), prc.getCommandArgs()); @@ -114,7 +114,7 @@ public void getUsers(PopulateRoomCommand prc) { } } - public void mute(MuteParticipantCommand mpc) { + public void mute(MuteUserCommand mpc) { System.out.println("Got mute request from FSApplication."); Client c = manager.getESLClient(); if (c.canSend()) { @@ -123,7 +123,7 @@ public void mute(MuteParticipantCommand mpc) { } } - public void eject(EjectParticipantCommand mpc) { + public void eject(EjectUserCommand mpc) { Client c = manager.getESLClient(); if (c.canSend()) { c.sendAsyncApiCommand( mpc.getCommand(), mpc.getCommandArgs()); diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/FreeswitchApplication.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/FreeswitchApplication.java index 8157bddb8024..e8a4e11ecf5f 100755 --- a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/FreeswitchApplication.java +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/FreeswitchApplication.java @@ -26,10 +26,10 @@ import java.util.concurrent.TimeUnit; import org.bigbluebutton.freeswitch.voice.freeswitch.actions.BroadcastConferenceCommand; import org.bigbluebutton.freeswitch.voice.freeswitch.actions.EjectAllUsersCommand; -import org.bigbluebutton.freeswitch.voice.freeswitch.actions.EjectParticipantCommand; +import org.bigbluebutton.freeswitch.voice.freeswitch.actions.EjectUserCommand; import org.bigbluebutton.freeswitch.voice.freeswitch.actions.FreeswitchCommand; -import org.bigbluebutton.freeswitch.voice.freeswitch.actions.MuteParticipantCommand; -import org.bigbluebutton.freeswitch.voice.freeswitch.actions.PopulateRoomCommand; +import org.bigbluebutton.freeswitch.voice.freeswitch.actions.MuteUserCommand; +import org.bigbluebutton.freeswitch.voice.freeswitch.actions.GetAllUsersCommand; import org.bigbluebutton.freeswitch.voice.freeswitch.actions.RecordConferenceCommand; public class FreeswitchApplication { @@ -58,23 +58,23 @@ private void queueMessage(FreeswitchCommand command) { } } - public void populateRoom(String room) { - PopulateRoomCommand prc = new PopulateRoomCommand(room, USER); + public void getAllUsers(String voiceConfId) { + GetAllUsersCommand prc = new GetAllUsersCommand(voiceConfId, USER); queueMessage(prc); } - public void mute(String room, String participant, Boolean mute) { - MuteParticipantCommand mpc = new MuteParticipantCommand(room, participant, mute, USER); + public void muteUser(String voiceConfId, String voiceUserId, Boolean mute) { + MuteUserCommand mpc = new MuteUserCommand(voiceConfId, voiceUserId, mute, USER); queueMessage(mpc); } - public void eject(String room, String participant) { - EjectParticipantCommand mpc = new EjectParticipantCommand(room, participant, USER); + public void eject(String voiceConfId, String voiceUserId) { + EjectUserCommand mpc = new EjectUserCommand(voiceConfId, voiceUserId, USER); queueMessage(mpc); } - public void ejectAll(String room) { - EjectAllUsersCommand mpc = new EjectAllUsersCommand(room, USER); + public void ejectAll(String voiceConfId) { + EjectAllUsersCommand mpc = new EjectAllUsersCommand(voiceConfId, USER); queueMessage(mpc); } @@ -82,28 +82,33 @@ private Long genTimestamp() { return TimeUnit.NANOSECONDS.toMillis(System.nanoTime()); } - public void record(String room, String meetingid){ + public void startRecording(String voiceConfId, String meetingid){ String RECORD_DIR = "/var/freeswitch/meetings"; String voicePath = RECORD_DIR + File.separatorChar + meetingid + "-" + genTimestamp() + ".wav"; - RecordConferenceCommand rcc = new RecordConferenceCommand(room, USER, true, voicePath); + RecordConferenceCommand rcc = new RecordConferenceCommand(voiceConfId, USER, true, voicePath); queueMessage(rcc); } + + public void stopRecording(String voiceConfId, String meetingid, String voicePath){ + RecordConferenceCommand rcc = new RecordConferenceCommand(voiceConfId, USER, false, voicePath); + queueMessage(rcc); + } private void sendMessageToFreeswitch(final FreeswitchCommand command) { Runnable task = new Runnable() { public void run() { - if (command instanceof PopulateRoomCommand) { - PopulateRoomCommand cmd = (PopulateRoomCommand) command; + if (command instanceof GetAllUsersCommand) { + GetAllUsersCommand cmd = (GetAllUsersCommand) command; System.out.println("Sending PopulateRoomCommand for conference = [" + cmd.getRoom() + "]"); manager.getUsers(cmd); - } else if (command instanceof MuteParticipantCommand) { - MuteParticipantCommand cmd = (MuteParticipantCommand) command; + } else if (command instanceof MuteUserCommand) { + MuteUserCommand cmd = (MuteUserCommand) command; System.out.println("Sending MuteParticipantCommand for conference = [" + cmd.getRoom() + "]"); System.out.println("Sending MuteParticipantCommand for conference = [" + cmd.getRoom() + "]"); manager.mute(cmd); - } else if (command instanceof EjectParticipantCommand) { - EjectParticipantCommand cmd = (EjectParticipantCommand) command; + } else if (command instanceof EjectUserCommand) { + EjectUserCommand cmd = (EjectUserCommand) command; System.out.println("Sending EjectParticipantCommand for conference = [" + cmd.getRoom() + "]"); manager.eject(cmd); } else if (command instanceof EjectAllUsersCommand) { diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/EjectParticipantCommand.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/EjectUserCommand.java similarity index 85% rename from labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/EjectParticipantCommand.java rename to labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/EjectUserCommand.java index e46deef3e470..aa5315710f46 100755 --- a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/EjectParticipantCommand.java +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/EjectUserCommand.java @@ -18,11 +18,11 @@ */ package org.bigbluebutton.freeswitch.voice.freeswitch.actions; -public class EjectParticipantCommand extends FreeswitchCommand { +public class EjectUserCommand extends FreeswitchCommand { private final String participant; - public EjectParticipantCommand(String room, String participant, String requesterId) { + public EjectUserCommand(String room, String participant, String requesterId) { super(room, requesterId); this.participant = participant; } diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/PopulateRoomCommand.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/GetAllUsersCommand.java similarity index 94% rename from labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/PopulateRoomCommand.java rename to labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/GetAllUsersCommand.java index 03f7a3229608..00482e01f154 100755 --- a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/PopulateRoomCommand.java +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/GetAllUsersCommand.java @@ -36,9 +36,9 @@ import org.xml.sax.SAXException; -public class PopulateRoomCommand extends FreeswitchCommand { +public class GetAllUsersCommand extends FreeswitchCommand { - public PopulateRoomCommand(String room, String requesterId) { + public GetAllUsersCommand(String room, String requesterId) { super(room, requesterId); } diff --git a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/MuteParticipantCommand.java b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/MuteUserCommand.java similarity index 86% rename from labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/MuteParticipantCommand.java rename to labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/MuteUserCommand.java index fdd7b343ebac..e015535302b1 100755 --- a/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/MuteParticipantCommand.java +++ b/labs/akka-bbb-fs/src/main/java/org/bigbluebutton/freeswitch/voice/freeswitch/actions/MuteUserCommand.java @@ -18,12 +18,12 @@ */ package org.bigbluebutton.freeswitch.voice.freeswitch.actions; -public class MuteParticipantCommand extends FreeswitchCommand { +public class MuteUserCommand extends FreeswitchCommand { private final String participant; private final Boolean mute; - public MuteParticipantCommand(String room, String participant, Boolean mute, String requesterId) { + public MuteUserCommand(String room, String participant, Boolean mute, String requesterId) { super(room, requesterId); this.participant = participant; this.mute = mute; diff --git a/labs/akka-bbb-fs/src/main/scala/org/bigbluebutton/endpoint/redis/RedisPublisher.scala b/labs/akka-bbb-fs/src/main/scala/org/bigbluebutton/endpoint/redis/RedisPublisher.scala index df8c7818a3fe..74fbb7d2a753 100755 --- a/labs/akka-bbb-fs/src/main/scala/org/bigbluebutton/endpoint/redis/RedisPublisher.scala +++ b/labs/akka-bbb-fs/src/main/scala/org/bigbluebutton/endpoint/redis/RedisPublisher.scala @@ -22,7 +22,7 @@ class RedisPublisher(val system: ActorSystem) extends SystemConfiguration { Await.result(futurePong, 5 seconds) // publish after 2 seconds every 2 or 5 seconds - system.scheduler.schedule(2 seconds, 2 seconds)(redis.publish("time", System.currentTimeMillis())) + //system.scheduler.schedule(2 seconds, 2 seconds)(redis.publish("time", System.currentTimeMillis())) // system.scheduler.schedule(2 seconds, 5 seconds)(redis.publish("bigbluebutton:to-bbb-apps:users", "pattern value")) def publish(channel: String, data: String) { diff --git a/labs/akka-bbb-fs/src/main/scala/org/bigbluebutton/freeswitch/VoiceConferenceService.scala b/labs/akka-bbb-fs/src/main/scala/org/bigbluebutton/freeswitch/VoiceConferenceService.scala index e4d56e7faf3f..8fc68d55dc53 100755 --- a/labs/akka-bbb-fs/src/main/scala/org/bigbluebutton/freeswitch/VoiceConferenceService.scala +++ b/labs/akka-bbb-fs/src/main/scala/org/bigbluebutton/freeswitch/VoiceConferenceService.scala @@ -3,58 +3,44 @@ package org.bigbluebutton.freeswitch import org.bigbluebutton.freeswitch.voice.IVoiceConferenceService import org.bigbluebutton.core.api._ import org.bigbluebutton.endpoint.redis.RedisPublisher - -case class FsVoiceUserJoined(userId: String, webUserId: String, - conference: String, callerIdNum: String, - callerIdName: String, muted: Boolean, - speaking: Boolean) - -case class FsVoiceUserLeft(userId: String, conference: String) -case class FsVoiceUserLocked(userId: String, conference: String, locked: Boolean) -case class FsVoiceUserMuted(userId: String, conference: String, muted: Boolean) -case class FsVoiceUserTalking(userId: String, conference: String, talking: Boolean) -case class FsRecording(conference: String, recordingFile: String, - timestamp: String, recording: Boolean) +import org.bigbluebutton.freeswitch.pubsub.messages._ class VoiceConferenceService(sender: RedisPublisher) extends IVoiceConferenceService { - def voiceStartedRecording(conference: String, recordingFile: String, - timestamp: String, recording: java.lang.Boolean) { - val fsRec = new FsRecording(conference, recordingFile, timestamp, recording) + val FROM_VOICE_CONF_SYSTEM_CHAN = "bigbluebutton:from-voice-conf:system"; + def voiceConfRecordingStarted(voiceConfId: String, recordStream: String, recording: java.lang.Boolean, timestamp: String) { + val msg = new VoiceConfRecordingStartedMessage(voiceConfId, recordStream, recording, timestamp) + sender.publish(FROM_VOICE_CONF_SYSTEM_CHAN, msg.toJson()) } - def voiceUserJoined(userId: String, webUserId: String, conference: String, - callerIdNum: String, callerIdName: String, - muted: java.lang.Boolean, talking: java.lang.Boolean) { + def userJoinedVoiceConf(voiceConfId: String, voiceUserId: String, userId: String, callerIdName: String, + callerIdNum: String, muted: java.lang.Boolean, talking: java.lang.Boolean) { // println("******** FreeswitchConferenceService received voiceUserJoined vui=[" + userId + "] wui=[" + webUserId + "]") - val vuj = new FsVoiceUserJoined(userId, webUserId, - conference, callerIdNum, - callerIdName, muted, - talking) - + val msg = new UserJoinedVoiceConfMessage(voiceConfId, voiceUserId, userId, + callerIdName, callerIdNum, muted, talking) + sender.publish(FROM_VOICE_CONF_SYSTEM_CHAN, msg.toJson()) } - def voiceUserLeft(userId: String, conference: String) { + def userLeftVoiceConf(voiceConfId: String, voiceUserId: String) { // println("******** FreeswitchConferenceService received voiceUserLeft vui=[" + userId + "] conference=[" + conference + "]") - val vul = new FsVoiceUserLeft(userId, conference) - + val msg = new UserLeftVoiceConfMessage(voiceConfId, voiceUserId) + sender.publish(FROM_VOICE_CONF_SYSTEM_CHAN, msg.toJson()) } - def voiceUserLocked(userId: String, conference: String, locked: java.lang.Boolean) { - val vul = new FsVoiceUserLocked(userId, conference, locked) + def userLockedInVoiceConf(voiceConfId: String, voiceUserId: String, locked: java.lang.Boolean) { } - def voiceUserMuted(userId: String, conference: String, muted: java.lang.Boolean) { - println("******** FreeswitchConferenceService received voiceUserMuted vui=[" + userId + "] muted=[" + muted + "]") - val vum = new FsVoiceUserMuted(userId, conference, muted) - + def userMutedInVoiceConf(voiceConfId: String, voiceUserId: String, muted: java.lang.Boolean) { + println("******** FreeswitchConferenceService received voiceUserMuted vui=[" + voiceUserId + "] muted=[" + muted + "]") + val msg = new UserMutedInVoiceConfMessage(voiceConfId, voiceUserId, muted) + sender.publish(FROM_VOICE_CONF_SYSTEM_CHAN, msg.toJson()) } - def voiceUserTalking(userId: String, conference: String, talking: java.lang.Boolean) { - println("******** FreeswitchConferenceService received voiceUserTalking vui=[" + userId + "] talking=[" + talking + "]") - val vut = new FsVoiceUserTalking(userId, conference, talking) - + def userTalkingInVoiceConf(voiceConfId: String, voiceUserId: String, talking: java.lang.Boolean) { + println("******** FreeswitchConferenceService received voiceUserTalking vui=[" + voiceUserId + "] talking=[" + talking + "]") + val msg = new UserTalkingInVoiceConfMessage(voiceConfId, voiceUserId, talking) + sender.publish(FROM_VOICE_CONF_SYSTEM_CHAN, msg.toJson()) } } \ No newline at end of file