1 <?php
2 require_once("serviceconfiguration.php");
3 ?>
4 <?php
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21 function _onApplicationStarted()
22 {
23 Logger::func("onApplictionStarted");
24 }
25
26
27
28
29
30
31
32
33
34
35
36
37 function _onApplicationStopped()
38 {
39 Logger::func("onApplicationStopped");
40 }
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56 @param
57
58 function _onClientWantsToConnect(&$client)
59 {
60 Logger::func("onClientWantsToConnect");
61
62 $client->AcceptConnection();
63 Logger::info("User ".$client->getUID()." wants to connect.");
64
65 $client->setNickName($client->getUID());
66 $BR = chr(13).chr(10);
67
68 $client->SendRoomMessage(
69 "Admin", "000000", "User \"" . $client->getNickName() .
70 "\" has entered the room.");
71
72 $client->SendPrivateMessage(
73 "Admin", $client->getUID(), "000000",
74 "This chat is written in Radical Chat Framework for PHP - ".
75 "the first available solution which enables developers ".
76 "to write flash videoconferencing applications entirely ".
77 "in PHP language without any further knowledge about ".
78 "Flash, Actionscript, RTMP protocol or stream server API. ".
79 "The framework unique design speeds up the video chat ".
80 "development process from 3-6 months to 2-4 days.".$BR.
81 "The design of this application could be altered by editing ".
82 "the XML configuration file on ".
83 "{{FONT COLOR='#0000FF'}}{{A HREF='config.xml' ".
84 "TARGET='_blank'}}./config.xml{{/A}}{{/FONT}}".$BR.
85 "The chat rules could be altered by editing ".
86 "{{FONT COLOR='#0000FF'}}{{A HREF='./service/service.php' ".
87 "TARGET='_blank'}}".
88 "./service/service.php file.".
89 "{{/A}}{{/FONT}}".$BR.
90 "If you want more information, please see ".
91 "{{FONT COLOR='#0000FF'}}".
92 "{{A HREF='http://en.cze.cz/Radical-Flash-Chat/' ".
93 "TARGET='_blank'}}".
94 "http://en.cze.cz/Radical-Flash-Chat/{{/A}}{{/FONT}}".$BR.$BR);
95 }
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110 @param
111
112
113 function _onClientConnectionWasAccepted(&$client)
114 {
115 Logger::func("onClientConnectionWasAccepted");
116 }
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131 @param
132
133
134 function _onClientConnectionWasRejected($client)
135 {
136 Logger::func("onClientConnectionWasRejected");
137 }
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152 @param
153
154
155 @param
156
157
158
159 function _onClientDisconnected($client, &$room = null)
160 {
161
162
163
164 Logger::func("onClientDisconnected");
165 Logger::info("User ".$client->getUID()." is disconnected.");
166
167 $room->SendRoomMessage("Admin","000000","User " .
168 $client->getNickName() . " left the room");
169 }
170
171
172
173
174
175
176
177
178
179
180
181
182
183 @param
184
185 @param
186
187 function _onClientWantsToStartStreaming(&$client, $stream)
188 {
189 Logger::func("onClientWantsToStartStreaming");
190
191
192 $client->setStreamingRejected();
193
194
195 $mutexName = "Mutex".$client->getRoomUID();
196 $mutex = new Mutex($mutexName);
197
198
199
200 $mutex->lock();
201 {
202
203 $po = new PersistentObject($mutexName);
204
205
206 if(!isset($po->vars["WhoIsStreaming"]))
207 {
208 $po->vars["WhoIsStreaming"] = "noone";
209 $po->vars["verified"] = time();
210 $po->save();
211 }
212
213
214 if(($po->vars["WhoIsStreaming"]=="noone") ||
215 (time() - $po->vars["verified"] > 3))
216 {
217
218
219
220 $client->setStreamingAccepted();
221
222 $client->SendPrivateMessage(
223 "Admin", $client->getUID(),"C00000", "You are " .
224 "attempting to start streaming.{{BR/}}{{BR/}} Information: " .
225 $stream->getInformations());
226
227
228 $po->vars["WhoIsStreaming"] = $client->getUID();
229 $po->vars["verified"] = time();
230 $po->save();
231
232
233 $ssc = $client->getStreamServerCommands();
234
235 $ssc->client_setNextCheckDefaultValue($client->getUID(), 3);
236 }
237 else
238 {
239
240 $client->SendPrivateMessage(
241 "Admin", $client->getUID(),"C00000", "Sorry ".
242 "your stream cannot be published because someone ".
243 "else \"".$po->vars["WhoIsStreaming"]."\" ".
244 "is streaming.");
245 }
246
247
248 $mutex->unlock();
249 }
250 }
251
252
253
254
255
256
257
258
259
260
261 @param
262 @param
263
264 function _onClientStoppedStreaming($client, $stream)
265 {
266 Logger::func("onClientStoppedStreaming");
267 }
268
269
270
271
272
273
274
275
276
277
278
279
280 @param
281
282 @param
283
284 function _onClientWantsToPlayStream(&$client, $stream)
285 {
286 Logger::func("onClientWantsToPlayStream");
287
288 $client->setPlayStreamAccepted();
289
290 $client->SendPrivateMessage(
291 "Admin",$client->getUID(),"00C000", "Client is " .
292 "attempting to play the stream.{{BR/}} Information are " .
293 $stream->getInformations());
294 }
295
296
297
298
299
300
301
302
303
304
305 @param
306
307 @param
308
309 function _onClientStoppedPlayingStream($client, $stream)
310 {
311 Logger::func("onClientStoppedPlayingStream");
312 }
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333 @param
334
335
336 function _onCheckClients(&$clients)
337 {
338 Logger::func("onCheckClients");
339 foreach($clients as $client)
340 {
341
342
343 $client = Client::castToClient($client);
344
345
346 $mutexName = "Mutex".$client->getRoomUID();
347 $mutex = new Mutex($mutexName);
348
349
350
351 $mutex->lock();
352 {
353
354 $po = new PersistentObject($mutexName);
355
356
357 $po->vars["WhoIsStreaming"] = $client->getUID();
358 $po->vars["verified"] = time();
359 $po->save();
360
361
362 $mutex->unlock();
363 }
364 }
365 }
366
367
368
369
370
371
372
373 @param
374
375 @param
376 @param
377 @param
378
379 function _onClientSendMessage(&$client,$toUID,$color,$message)
380 {
381 Logger::func("onClientSendMessage");
382 Logger::info($message);
383 $prefix = "prefix ";
384 $postfix = " postfix. This message was altered on the fly.".
385 $client->SendPrivateMessage($client->getNickName(), $toUID, $color,
386 $prefix . $message . $postfix);
387 }
388
389
390
391
392
393
394
395
396
397
398
399
400 @param
401 @param
402
403 @param
404
405 @param
406
407 function _onUniversalCall(&$clients,$senderName,$eventName,$value)
408 {
409 Logger::func("onUniversalCall");
410
411
412
413
414 if($eventName==ChatEvents::$EVENT_BASICBUTTONCLICKED_WITHSELECTEDCLIENTS)
415 {
416
417 if($senderName=="KickOutButton")
418 {
419
420 $clientWhoIsKickingOut = Client::castToClient($clients[0]);
421 $clientWhoIsKickingOut->SendPrivateMessage(
422 "Admin",$clientWhoIsKickingOut->getUID(),"000000",
423 "You are attempting to KickOut clients.");
424
425
426 for($a = 1; $a<sizeof($clients); $a++)
427 {
428 $clients[$a]->SendPrivateMessage(
429 "Admin",$clients[$a]->getUID(),"000000",
430 "You were kicked out by " .
431 $clientWhoIsKickingOut->getNickName());
432 }
433 }
434
435
436 if($senderName=="PrivateButton")
437 {
438
439 $client = Client::castToClient($clients[0]);
440 $client->SendPrivateMessage("Admin", $client->getUID(),
441 "000000", "You are trying to invite some other ".
442 "user to the private chat. ".
443 "Take a look on service.php - event ".
444 "onUniversalCall and setup private chat there.");
445
446 $ssc = $client->getStreamServerCommands();
447
448
449 $ssc->client_OpenWebPage($client->getUID(),
450 "index.php","_blank");
451
452
453
454 }
455 }
456 }
457
458
459
460
461
462
463
464
465
466
467 @param
468
469
470 function _onChatRoomCreated(&$room)
471 {
472 Logger::func("onChatRoomCreated");
473
474 $room->SendRoomMessage("Admin","00FF00",
475 "Chat room has been created");
476
477 $ssc = $room->getStreamServerCommands();
478 $skin = $ssc->room_getSkin($room->getUID());
479
480 $skin->updateSkinObject(
481 '<Skin><BG><SkinObject><Type>HtmlTextArea</Type>
482 <Name>RoomName</Name>
483 <Visible>true</Visible>
484 <Position>
485 <Left>{PerformerVideoPanel.Left}+10</Left>
486 <Top>{PerformerVideoPanel.Top}+5</Top>
487 <Width>400</Width>
488 <Height>50</Height>
489 </Position>'.
490 '<HtmlText>{{FONT SIZE="12" COLOR="#000000" '.
491 'LETTERSPACING="0" KERNING="0"}}'.
492 '{{B}}'.$room->getUID().'{{/B}}{{/FONT}}</HtmlText>'.
493 '<IsTextSelectable>false</IsTextSelectable>
494 </SkinObject></BG></Skin>');
495 }
496
497
498
499
500
501
502
503
504
505
506
507
508 @param
509
510
511 function _onCheckChatRooms(&$rooms)
512 {
513 Logger::func("onCheckChatRooms");
514 foreach($rooms as $room)
515 {
516
517 }
518 }
519
520
521
522
523
524
525
526
527
528
529
530 @param
531
532 function _onChatRoomClosed($room)
533 {
534 Logger::func("onChatRoomClosed");
535 }
536
537
538
539
540 ?>
541 <?php
542
543 require_once("servicehandler.php");
544 ?>
545