34
34
import org .red5 .server .api .IContext ;
35
35
import org .red5 .server .api .scope .IScope ;
36
36
import org .slf4j .Logger ;
37
- import org .springframework .context .ApplicationEvent ;
38
- import org .springframework .context .ApplicationListener ;
39
- import org .springframework .context .support .AbstractApplicationContext ;
40
37
import com .google .gson .Gson ;
41
38
42
39
public class BigBlueButtonApplication extends MultiThreadedApplicationAdapter {
43
40
private static Logger log = Red5LoggerFactory .getLogger (BigBlueButtonApplication .class , "bigbluebutton" );
44
41
45
42
private RecorderApplication recorderApplication ;
46
- private AbstractApplicationContext appCtx ;
47
43
private ConnectionInvokerService connInvokerService ;
48
44
private IBigBlueButtonInGW bbbGW ;
49
45
50
46
private static final String APP = "BBB" ;
51
47
52
48
@ Override
53
49
public boolean appConnect (IConnection conn , Object [] params ) {
54
- log .debug ("***** " + APP + " [ " + " appConnect *********" );
55
50
return super .appConnect (conn , params );
56
51
}
57
52
58
53
@ Override
59
54
public void appDisconnect (IConnection conn ) {
60
- log .debug ("***** " + APP + " [ " + " appDisconnect *********" );
61
55
super .appDisconnect (conn );
62
56
}
63
57
64
58
@ Override
65
59
public boolean appJoin (IClient client , IScope scope ) {
66
- log .debug ("***** " + APP + " [ " + " appJoin [ " + scope .getName () + "] *********" );
67
60
return super .appJoin (client , scope );
68
61
}
69
62
70
63
@ Override
71
64
public void appLeave (IClient client , IScope scope ) {
72
- log .debug ("***** " + APP + " [ " + " appLeave [ " + scope .getName () + "] *********" );
73
65
super .appLeave (client , scope );
74
66
}
75
67
76
68
@ Override
77
69
public boolean roomJoin (IClient client , IScope scope ) {
78
- log .debug ("***** " + APP + " [ " + " roomJoin [ " + scope .getName () + "] *********" );
79
70
return super .roomJoin (client , scope );
80
71
}
81
72
82
73
@ Override
83
74
public void roomLeave (IClient client , IScope scope ) {
84
- log .debug ("***** " + APP + " [ " + " roomLeave [ " + scope .getName () + "] *********" );
85
75
super .roomLeave (client , scope );
86
76
}
87
77
88
78
@ Override
89
- public boolean appStart (IScope app ) {
90
- log .debug ("***** " + APP + " [ " + " appStart [ " + scope .getName () + "] *********" );
91
- IContext context = app .getContext ();
92
- appCtx = (AbstractApplicationContext ) context .getApplicationContext ();
93
- appCtx .addApplicationListener (new ShutdownHookListener ());
94
- appCtx .registerShutdownHook ();
95
- super .appStart (app );
96
-
79
+ public boolean appStart (IScope app ) {
80
+ super .appStart (app );
97
81
connInvokerService .setAppScope (app );
98
-
99
82
return true ;
100
83
}
101
84
102
85
@ Override
103
86
public void appStop (IScope app ) {
104
- log .debug ("***** " + APP + " [ " + " appStop [ " + scope .getName () + "] *********" );
105
87
super .appStop (app );
106
88
}
107
89
108
90
@ Override
109
91
public boolean roomStart (IScope room ) {
110
- log .debug ("***** " + APP + " [ " + " roomStart [ " + scope .getName () + "] *********" );
111
-
112
92
connInvokerService .addScope (room .getName (), room );
113
93
return super .roomStart (room );
114
94
}
115
95
116
96
@ Override
117
97
public void roomStop (IScope room ) {
118
- log .debug ("***** " + APP + " [ " + " roomStop [ " + scope .getName () + "] *********" );
119
-
120
98
recorderApplication .destroyRecordSession (room .getName ());
121
99
connInvokerService .removeScope (room .getName ());
122
100
@@ -125,8 +103,6 @@ public void roomStop(IScope room) {
125
103
126
104
@ Override
127
105
public boolean roomConnect (IConnection connection , Object [] params ) {
128
- log .debug ("***** " + APP + " [ " + " roomConnect [ " + connection .getScope ().getName () + "] *********" );
129
-
130
106
String username = ((String ) params [0 ]).toString ();
131
107
String role = ((String ) params [1 ]).toString ();
132
108
String room = ((String )params [2 ]).toString ();
@@ -181,7 +157,7 @@ boolean record = (Boolean)params[4];
181
157
String connId = Red5 .getConnectionLocal ().getSessionId ();
182
158
183
159
log .info ("User connected: sessionId=[" + connId + "], encoding=[" + connType +
184
- "(persistent=RTMP,polling=RTMPT) ], meetingId= [" + meetingId
160
+ "], meetingId= [" + meetingId
185
161
+ "], userId=[" + userId + "] username=[" + userFullname +"]" );
186
162
187
163
@@ -215,8 +191,7 @@ private String getConnectionType(String connType) {
215
191
216
192
@ Override
217
193
public void roomDisconnect (IConnection conn ) {
218
- log .debug ("***** " + APP + " [ " + " roomDisconnect [ " + conn .getScope ().getName () + "] *********" );
219
-
194
+
220
195
String remoteHost = Red5 .getConnectionLocal ().getRemoteAddress ();
221
196
int remotePort = Red5 .getConnectionLocal ().getRemotePort ();
222
197
String clientId = Red5 .getConnectionLocal ().getClient ().getId ();
@@ -233,7 +208,7 @@ public void roomDisconnect(IConnection conn) {
233
208
String connId = Red5 .getConnectionLocal ().getSessionId ();
234
209
235
210
log .info ("User disconnected: sessionId=[" + connId + "], encoding=[" + connType +
236
- "(persistent=RTMP,polling=RTMPT) ], meetingId= [" + meetingId + "], userId=[" + userId + "] username=[" + userFullname +"]" );
211
+ "], meetingId= [" + meetingId + "], userId=[" + userId + "] username=[" + userFullname +"]" );
237
212
238
213
Map <String , Object > logData = new HashMap <String , Object >();
239
214
logData .put ("meetingId" , meetingId );
@@ -293,15 +268,4 @@ public void setConnInvokerService(ConnectionInvokerService connInvokerService) {
293
268
public void setBigBlueButtonInGW (IBigBlueButtonInGW bbbGW ) {
294
269
this .bbbGW = bbbGW ;
295
270
}
296
-
297
- private class ShutdownHookListener implements ApplicationListener <ApplicationEvent > {
298
-
299
- @ Override
300
- public void onApplicationEvent (ApplicationEvent event ) {
301
- if (event instanceof org .springframework .context .event .ContextStoppedEvent ) {
302
- log .info ("Received shutdown event. Red5 is shutting down. Destroying all rooms." );
303
- }
304
- }
305
-
306
- }
307
271
}
0 commit comments