Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rewrote services to use new message system #29

Merged
Diff settings

Always

Just for now

@@ -6,8 +6,6 @@ package org.bigbluebutton
import org.bigbluebutton.command.ConnectSignal;
import org.bigbluebutton.command.DisconnectUserCommand;
import org.bigbluebutton.command.DisconnectUserSignal;
import org.bigbluebutton.command.LoadPresentationCommand;
import org.bigbluebutton.command.LoadPresentationSignal;
import org.bigbluebutton.command.LoadSlideCommand;
import org.bigbluebutton.command.LoadSlideSignal;
import org.bigbluebutton.command.ShareCameraCommand;
@@ -20,32 +18,28 @@ package org.bigbluebutton
import org.bigbluebutton.core.ChatMessageSender;
import org.bigbluebutton.core.ChatMessageService;
import org.bigbluebutton.core.DeskshareConnection;
import org.bigbluebutton.core.DeskshareService;
import org.bigbluebutton.core.DeskshareServiceSO;
import org.bigbluebutton.core.IBaseConnection;
import org.bigbluebutton.core.IBigBlueButtonConnection;
import org.bigbluebutton.core.IChatMessageReceiver;
import org.bigbluebutton.core.IChatMessageSender;
import org.bigbluebutton.core.IChatMessageService;
import org.bigbluebutton.core.IDeskshareConnection;
import org.bigbluebutton.core.IDeskshareService;
import org.bigbluebutton.core.IDeskshareServiceSO;
import org.bigbluebutton.core.IListenersServiceSO;
import org.bigbluebutton.core.ILoginService;
import org.bigbluebutton.core.IPresentMessageSender;
import org.bigbluebutton.core.IPresentMessageReceiver;
import org.bigbluebutton.core.IPresentServiceSO;
import org.bigbluebutton.core.IPresentationService;
import org.bigbluebutton.core.IUsersService;
import org.bigbluebutton.core.IUsersServiceSO;
import org.bigbluebutton.core.IVideoConnection;
import org.bigbluebutton.core.UsersService;
import org.bigbluebutton.core.IPresentationService;
import org.bigbluebutton.core.IUsersMessageSender;
import org.bigbluebutton.core.UsersMessageSender;
import org.bigbluebutton.core.IUsersMessageReceiver;
import org.bigbluebutton.core.UsersMessageReceiver;
import org.bigbluebutton.core.IVoiceConnection;
import org.bigbluebutton.core.ListenersServiceSO;
import org.bigbluebutton.core.IVideoConnection;
import org.bigbluebutton.core.LoginService;
import org.bigbluebutton.core.PresentMessageSender;
import org.bigbluebutton.core.PresentMessageReceiver;
import org.bigbluebutton.core.PresentServiceSO;
import org.bigbluebutton.core.PresentationService;
import org.bigbluebutton.core.UsersService;
import org.bigbluebutton.core.UsersServiceSO;
import org.bigbluebutton.core.VideoConnection;
import org.bigbluebutton.core.VoiceConnection;
import org.bigbluebutton.model.ConferenceParameters;
@@ -56,6 +50,8 @@ package org.bigbluebutton
import org.bigbluebutton.model.UserUISession;
import org.bigbluebutton.model.chat.ChatMessagesSession;
import org.bigbluebutton.model.chat.IChatMessagesSession;



import robotlegs.bender.extensions.signalCommandMap.api.ISignalCommandMap;
import robotlegs.bender.framework.api.IConfig;
@@ -75,32 +71,29 @@ package org.bigbluebutton
injector.map(IUserUISession).toSingleton(UserUISession);
injector.map(IUserSession).toSingleton(UserSession);
injector.map(IConferenceParameters).toSingleton(ConferenceParameters);
injector.map(IUsersMessageReceiver).toSingleton(UsersMessageReceiver);
injector.map(IUsersService).toSingleton(UsersService);
injector.map(IUsersMessageSender).toSingleton(UsersMessageSender);

This comment has been minimized.

Copy link
@capilkey

capilkey Jun 17, 2014

Member

Do the message senders and receivers need to be singletons?

This comment has been minimized.

Copy link
@capilkey

capilkey Jun 17, 2014

Member

After looking at these senders and receivers closer I don't think you need to map them at all. You can just create and set them in their corresponding services.

injector.map(IChatMessageService).toSingleton(ChatMessageService);
injector.map(IChatMessageReceiver).toSingleton(ChatMessageReceiver);
injector.map(IChatMessageSender).toSingleton(ChatMessageSender);
injector.map(IPresentationService).toSingleton(PresentationService);
injector.map(IPresentMessageSender).toSingleton(PresentMessageSender);
injector.map(IPresentMessageReceiver).toSingleton(PresentMessageReceiver);
injector.map(IChatMessagesSession).toSingleton(ChatMessagesSession);
injector.map(IDeskshareConnection).toSingleton(DeskshareConnection);
injector.map(IDeskshareService).toSingleton(DeskshareService);

// Type mapping
injector.map(IBaseConnection).toType(BaseConnection);
injector.map(IVoiceConnection).toType(VoiceConnection);
injector.map(ILoginService).toType(LoginService);
injector.map(IUsersServiceSO).toType(UsersServiceSO);
injector.map(IListenersServiceSO).toType(ListenersServiceSO);
injector.map(IPresentServiceSO).toType(PresentServiceSO);
injector.map(IDeskshareServiceSO).toType(DeskshareServiceSO);
injector.map(IBigBlueButtonConnection).toType(BigBlueButtonConnection);
injector.map(IVideoConnection).toType(VideoConnection);

// Signal to Command mapping
signalCommandMap.map(ConnectSignal).toCommand(ConnectCommand);
signalCommandMap.map(ShareMicrophoneSignal).toCommand(ShareMicrophoneCommand);
signalCommandMap.map(ShareCameraSignal).toCommand(ShareCameraCommand);
signalCommandMap.map(LoadPresentationSignal).toCommand(LoadPresentationCommand);
signalCommandMap.map(LoadSlideSignal).toCommand(LoadSlideCommand);
signalCommandMap.map(CameraQualitySignal).toCommand(CameraQualityCommand);
signalCommandMap.map(DisconnectUserSignal).toCommand(DisconnectUserCommand);
@@ -8,7 +8,6 @@ package org.bigbluebutton.command
import org.bigbluebutton.core.IBigBlueButtonConnection;
import org.bigbluebutton.core.IChatMessageService;
import org.bigbluebutton.core.IDeskshareConnection;
import org.bigbluebutton.core.IDeskshareService;
import org.bigbluebutton.core.IPresentationService;
import org.bigbluebutton.core.IUsersService;
import org.bigbluebutton.core.IVideoConnection;
@@ -56,9 +55,6 @@ package org.bigbluebutton.command
[Inject]
public var presentationService: IPresentationService;

[Inject]
public var deskshareService: IDeskshareService;

override public function execute():void {
connection.uri = uri;

@@ -68,51 +64,69 @@ package org.bigbluebutton.command
connection.connect(conferenceParameters);
}

private function successConnected():void {
private function successConnected():void {
Log.getLogger("org.bigbluebutton").info(String(this) + ":successConnected()");

userSession.mainConnection = connection;
userSession.userId = connection.userId;

usersService.connectUsers(uri);
// Setup all the message receivers for the services that use the BigBlueButtonConnection:
usersService.setupMessageReceiver();
chatService.setupMessageReceiver();
presentationService.setupMessageReceiver();

This comment has been minimized.

Copy link
@capilkey

capilkey Jun 17, 2014

Member

I think it would be better to setup the chat and presentation services after the userSession.success has been received.


// Send the join meeting message, then wait for the reponse
userSession.successJoiningMeetingSignal.add(successJoiningMeeting);
userSession.unsuccessJoiningMeetingSignal.add(unsuccessJoiningMeeting);

usersService.sendJoinMeetingMessage();

connection.successConnected.remove(successConnected);
connection.unsuccessConnected.remove(unsuccessConnected);
}

private function successJoiningMeeting():void {

// set up and connect the remaining connections
videoConnection.uri = userSession.config.getConfigFor("VideoConfModule").@uri + "/" + conferenceParameters.room;

//TODO use proper callbacks
//TODO see if videoConnection.successConnected is dispatched when it's connected properly
videoConnection.successConnected.add(successVideoConnected);
videoConnection.unsuccessConnected.add(unsuccessVideoConnected);

videoConnection.connect();

userSession.videoConnection = videoConnection;

voiceConnection.uri = userSession.config.getConfigFor("PhoneModule").@uri;
userSession.voiceConnection = voiceConnection;

usersService.connectListeners(uri);

deskshareConnection.applicationURI = userSession.config.getConfigFor("DeskShareModule").@uri;
deskshareConnection.room = conferenceParameters.room;
deskshareConnection.connect();

userSession.deskshareConnection = deskshareConnection;
deskshareService.connectDeskshareSO();
deskshareService.checkIfStreamIsPublishing(conferenceParameters.room);

userSession.deskshareConnection = deskshareConnection;

// Query the server for chat, users, and presentation info
chatService.sendWelcomeMessage();
chatService.getPublicChatMessages();

presentationService.getPresentationInfo();

userSession.userList.allUsersAddedSignal.add(successUsersAdded);
usersService.queryForParticipants();

presentationService.connectPresent(uri);
userSession.successJoiningMeetingSignal.remove(successJoiningMeeting);
userSession.unsuccessJoiningMeetingSignal.remove(unsuccessJoiningMeeting);
}

private function unsuccessJoiningMeeting():void {
trace("ConnectCommand::unsuccessJoiningMeeting() -- Failed to join the meeting!!!");

connection.successConnected.remove(successConnected);
connection.unsuccessConnected.remove(unsuccessConnected);
userSession.successJoiningMeetingSignal.remove(successJoiningMeeting);
userSession.unsuccessJoiningMeetingSignal.remove(unsuccessJoiningMeeting);
}

/**
* Raised when we receive signal from UserServiceSO.as that all participants were added.
* Now we can switch from loading screen to participants screen
*/
private function successUsersAdded():void
{
userUISession.loading = false;

This file was deleted.

Oops, something went wrong.

This file was deleted.

Oops, something went wrong.
@@ -20,7 +20,7 @@ package org.bigbluebutton.core
{
[Inject]
public var disconnectUserSignal:DisconnectUserSignal;

public static const NAME:String = "BaseConnection";

protected var _successConnected:ISignal = new Signal();
@@ -29,7 +29,7 @@ package org.bigbluebutton.core
protected var _netConnection:NetConnection;
protected var _uri:String;
protected var _onUserCommand:Boolean;

public function BaseConnection() {
Log.getLogger("org.bigbluebutton").info(String(this));
}
@@ -60,8 +60,16 @@ package org.bigbluebutton.core

public function connect(uri:String, ...parameters):void {
_uri = uri;

// The connect call needs to be done properly. At the moment lock settings
// are not implemented in the mobile client, so parameters[7] and parameters[8]
// are "faked" in order to connect (without them, I couldn't get the connect
// call to work...) - Adam
parameters[7] = false;
parameters[8] = false;

try {
trace("Connecting to " + uri + "[" + parameters + "]");
trace("Trying to connect to [" + uri + "] ...");
// passing an array to a method that expects a variable number of parameters
// http://stackoverflow.com/a/3852920
_netConnection.connect.apply(null, new Array(uri).concat(parameters));
@@ -130,7 +138,7 @@ package org.bigbluebutton.core
break;
}
}

protected function sendConnectionSuccessEvent():void
{
successConnected.dispatch();
@@ -161,15 +169,15 @@ package org.bigbluebutton.core
}

public function sendMessage(service:String, onSuccess:Function, onFailure:Function, message:Object=null):void {
trace("SENDING [" + service + "]");
trace("SENDING MESSAGE: [" + service + "]");
var responder:Responder = new Responder(
function(result:Object):void { // On successful result
onSuccess("Successfully sent [" + service + "].");
onSuccess("SUCCESSFULLY SENT: [" + service + "].");
},
function(status:Object):void { // status - On error occurred
var errorReason:String = "Failed to send [" + service + "]:\n";
var errorReason:String = "FAILED TO SEND: [" + service + "]:";
for (var x:Object in status) {
errorReason += "\t" + x + " : " + status[x];
errorReason += "\n - " + x + " : " + status[x];
}
onFailure(errorReason);
}
Oops, something went wrong.
ProTip! Use n and p to navigate between commits in a pull request.
You can’t perform that action at this time.