25
25
import org .red5 .logging .Red5LoggerFactory ;
26
26
import org .red5 .server .adapter .IApplication ;
27
27
import org .red5 .server .adapter .MultiThreadedApplicationAdapter ;
28
+ import org .red5 .server .api .IClient ;
28
29
import org .red5 .server .api .IConnection ;
29
30
import org .red5 .server .api .IContext ;
30
31
import org .red5 .server .api .scope .IScope ;
@@ -40,98 +41,132 @@ public class BigBlueButtonApplication extends MultiThreadedApplicationAdapter {
40
41
private RecorderApplication recorderApplication ;
41
42
private AbstractApplicationContext appCtx ;
42
43
private ConnectionInvokerService connInvokerService ;
43
-
44
+
45
+ private static final String APP = "BBB" ;
46
+
47
+ @ Override
48
+ public boolean appConnect (IConnection conn , Object [] params ) {
49
+ log .debug ("***** " + APP + " [ " + " appConnect *********" );
50
+ return super .appConnect (conn , params );
51
+ }
52
+
53
+ @ Override
54
+ public void appDisconnect (IConnection conn ) {
55
+ log .debug ("***** " + APP + " [ " + " appDisconnect *********" );
56
+ super .appDisconnect (conn );
57
+ }
58
+
59
+ @ Override
60
+ public boolean appJoin (IClient client , IScope scope ) {
61
+ log .debug ("***** " + APP + " [ " + " appJoin [ " + scope .getName () + "] *********" );
62
+ return super .appJoin (client , scope );
63
+ }
64
+
65
+ @ Override
66
+ public void appLeave (IClient client , IScope scope ) {
67
+ log .debug ("***** " + APP + " [ " + " appLeave [ " + scope .getName () + "] *********" );
68
+ super .appLeave (client , scope );
69
+ }
70
+
71
+ @ Override
72
+ public boolean roomJoin (IClient client , IScope scope ) {
73
+ log .debug ("***** " + APP + " [ " + " roomJoin [ " + scope .getName () + "] *********" );
74
+ return super .roomJoin (client , scope );
75
+ }
76
+
77
+ @ Override
78
+ public void roomLeave (IClient client , IScope scope ) {
79
+ log .debug ("***** " + APP + " [ " + " roomLeave [ " + scope .getName () + "] *********" );
80
+ super .roomLeave (client , scope );
81
+ }
82
+
44
83
@ Override
45
84
public boolean appStart (IScope app ) {
46
- log . debug ( "Starting BigBlueButton " );
85
+ log . debug ( "***** " + APP + " [ " + " appStart [ " + scope . getName () + "] *********" );
47
86
IContext context = app .getContext ();
48
87
appCtx = (AbstractApplicationContext ) context .getApplicationContext ();
49
88
appCtx .addApplicationListener (new ShutdownHookListener ());
50
89
appCtx .registerShutdownHook ();
51
- return super .appStart (app );
90
+ super .appStart (app );
91
+
92
+ connInvokerService .start ();
93
+
94
+ return true ;
52
95
}
53
96
54
97
@ Override
55
98
public void appStop (IScope app ) {
56
- log .debug ("Stopping BigBlueButton " );
99
+ log .debug ("***** " + APP + " [ " + " appStop [ " + scope .getName () + "] *********" );
100
+ connInvokerService .stop ();
57
101
super .appStop (app );
58
102
}
59
103
60
104
@ Override
61
105
public boolean roomStart (IScope room ) {
62
- log .debug ("Starting room [ " + room .getName () + "]. " );
63
- assert participantsApplication != null ;
64
- connInvokerService .addScope (room .getName (), room );
106
+ log .debug ("***** " + APP + " [ " + " roomStart [ " + scope .getName () + "] ********* " );
107
+
108
+ connInvokerService .addScope (room .getName (), room );
65
109
return super .roomStart (room );
66
110
}
67
111
68
112
@ Override
69
113
public void roomStop (IScope room ) {
70
- log .debug ("Stopping room [" + room .getName () + "]." );
71
- super .roomStop (room );
72
- assert participantsApplication != null ;
114
+ log .debug ("***** " + APP + " [ " + " roomStop [ " + scope .getName () + "] *********" );
115
+
73
116
participantsApplication .destroyRoom (room .getName ());
74
117
BigBlueButtonSession bbbSession = getBbbSession ();
75
- assert bbbSession != null ;
76
118
77
- /**
78
- * Need to figure out if the next 2 lines should be removed. (ralam nov 25, 2010).
79
- */
80
- assert recorderApplication != null ;
81
119
recorderApplication .destroyRecordSession (bbbSession .getSessionName ());
82
120
connInvokerService .removeScope (room .getName ());
83
- log .debug ("Stopped room [" + room .getName () + "]." );
121
+
122
+ super .roomStop (room );
84
123
}
85
124
86
125
@ Override
87
126
public boolean roomConnect (IConnection connection , Object [] params ) {
88
- String remoteHost = Red5 . getConnectionLocal ().getRemoteAddress ( );
89
- int remotePort = Red5 . getConnectionLocal (). getRemotePort ();
127
+ log . debug ( "***** " + APP + " [ " + " roomConnect [ " + connection . getScope ().getName () + "] *********" );
128
+
90
129
String username = ((String ) params [0 ]).toString ();
91
130
String role = ((String ) params [1 ]).toString ();
92
131
String conference = ((String )params [2 ]).toString ();
93
132
94
- /*
95
- * Convert the id to Long because it gets converted to ascii decimal
96
- * equivalent (i.e. zero (0) becomes 48) if we don't.
97
- */
98
- long clientID = Long .parseLong (Red5 .getConnectionLocal ().getClient ().getId ());
99
133
String sessionName = ((String )params [3 ]).toString ();
100
- log .info ("[clientid=" + clientID + "] connected from " + remoteHost + ":" + remotePort + "." );
101
-
134
+
102
135
String voiceBridge = ((String ) params [4 ]).toString ();
103
136
String room = sessionName ;
104
- assert recorderApplication != null ;
137
+
105
138
boolean record = (Boolean )params [5 ];
106
- log .debug ("record value - [" + record + "]" );
107
-
139
+
108
140
String externalUserID = ((String ) params [6 ]).toString ();
109
141
String internalUserID = ((String ) params [7 ]).toString ();
110
142
111
143
if (record == true ) {
112
144
recorderApplication .createRecordSession (sessionName );
113
145
}
114
146
115
- BigBlueButtonSession bbbSession = new BigBlueButtonSession (sessionName , clientID , internalUserID , username , role ,
147
+ BigBlueButtonSession bbbSession = new BigBlueButtonSession (sessionName , internalUserID , username , role ,
116
148
conference , room , voiceBridge , record , externalUserID );
117
149
connection .setAttribute (Constants .SESSION , bbbSession );
118
150
119
151
String debugInfo = "internalUserID=" + internalUserID + ",username=" + username + ",role=" + role + ",conference=" + conference + "," +
120
152
"session=" + sessionName + ",voiceConf=" + voiceBridge + ",room=" + room + ",externalUserid=" + externalUserID ;
121
153
log .debug ("User [{}] connected to room [{}]" , debugInfo , room );
122
154
participantsApplication .createRoom (room );
123
- super .roomConnect (connection , params );
124
-
155
+
125
156
connInvokerService .addConnection (bbbSession .getInternalUserID (), connection );
126
- return true ;
157
+
158
+ return super .roomConnect (connection , params );
159
+
127
160
}
128
161
129
162
@ Override
130
163
public void roomDisconnect (IConnection conn ) {
164
+ log .debug ("***** " + APP + " [ " + " roomDisconnect [ " + conn .getScope ().getName () + "] *********" );
165
+
131
166
String remoteHost = Red5 .getConnectionLocal ().getRemoteAddress ();
132
167
int remotePort = Red5 .getConnectionLocal ().getRemotePort ();
133
168
String clientId = Red5 .getConnectionLocal ().getClient ().getId ();
134
- log .info ("[clientid=" + clientId + "] disconnnected from " + remoteHost + ":" + remotePort + "." );
169
+ log .info ("***** " + APP + " [clientid=" + clientId + "] disconnnected from " + remoteHost + ":" + remotePort + "." );
135
170
136
171
connInvokerService .removeConnection (getBbbSession ().getInternalUserID ());
137
172
@@ -167,7 +202,6 @@ private BigBlueButtonSession getBbbSession() {
167
202
}
168
203
169
204
public void setConnInvokerService (ConnectionInvokerService connInvokerService ) {
170
- System .out .print ("Setting conn invoket service!!!!" );
171
205
this .connInvokerService = connInvokerService ;
172
206
}
173
207
0 commit comments