This repository was archived by the owner on Feb 10, 2025. It is now read-only.
File tree Expand file tree Collapse file tree 4 files changed +22
-33
lines changed Expand file tree Collapse file tree 4 files changed +22
-33
lines changed Original file line number Diff line number Diff line change 1
- # These are supported funding model platforms
2
-
3
- github : # Replace with up to 4 GitHub Sponsors-enabled usernames e.g., [user1, user2]
4
- patreon : ctf0
5
- open_collective : # Replace with a single Open Collective username
6
- ko_fi : # Replace with a single Ko-fi username
7
- tidelift : # Replace with a single Tidelift platform-name/package-name e.g., npm/babel
8
- community_bridge : # Replace with a single Community Bridge project-name e.g., cloud-foundry
9
- liberapay : # Replace with a single Liberapay username
10
- issuehunt : # Replace with a single IssueHunt username
11
- otechie : # Replace with a single Otechie username
12
- custom : # Replace with up to 4 custom sponsorship URLs e.g., ['link1', 'link2']
1
+ github : ctf0
Original file line number Diff line number Diff line change 16
16
}
17
17
],
18
18
"require" : {
19
- "illuminate/support" : " >=5.5 <9 .0" ,
19
+ "illuminate/support" : " >=5.5 <10 .0" ,
20
20
"kreait/firebase-php" : " *"
21
21
},
22
22
"suggest" : {
45
45
},
46
46
"funding" : [
47
47
{
48
- "type" : " patreon " ,
49
- "url" : " https://www.patreon. com/ctf0"
48
+ "type" : " github " ,
49
+ "url" : " https://github. com/sponsors /ctf0"
50
50
}
51
51
]
52
52
}
Original file line number Diff line number Diff line change 4
4
5
5
use Illuminate \Support \Arr ;
6
6
use Illuminate \Support \Str ;
7
- use Kreait \Firebase \ServiceAccount ;
8
- use Morrislaptop \Firestore \Factory ;
7
+ use Kreait \Firebase \Factory ;
9
8
use Kreait \Firebase \Exception \ApiException ;
10
9
use Illuminate \Broadcasting \BroadcastException ;
11
10
use Illuminate \Broadcasting \Broadcasters \Broadcaster ;
@@ -15,18 +14,20 @@ class FSDB extends Broadcaster
15
14
use Common;
16
15
17
16
protected $ db ;
17
+
18
18
protected $ config ;
19
19
20
20
/**
21
21
* Create a new broadcaster instance.
22
+ *
23
+ * @param mixed $config
22
24
*/
23
25
public function __construct ($ config )
24
26
{
25
- $ sr_account = ServiceAccount::fromJsonFile (base_path ($ config ['creds_file ' ]));
26
27
$ this ->config = $ config ;
27
28
$ this ->db = (new Factory ())
28
- ->withServiceAccount ($ sr_account )
29
- -> createFirestore ();
29
+ ->withServiceAccount ($ config [ ' creds_file ' ] )
30
+ -> createDatabase ();
30
31
}
31
32
32
33
/**
@@ -35,11 +36,11 @@ public function __construct($config)
35
36
public function broadcast (array $ channels , $ event , array $ payload = [])
36
37
{
37
38
$ db = $ this ->db ;
39
+ $ coll = $ db ->collection ($ this ->config ['collection_name ' ]);
38
40
$ socket = Arr::pull ($ payload , 'socket ' );
39
41
40
42
foreach ($ this ->formatChannels ($ channels ) as $ channel ) {
41
43
try {
42
- $ coll = $ db ->collection ($ this ->config ['collection_name ' ]);
43
44
$ doc = $ coll ->document (md5 (Str::uuid ()));
44
45
$ doc ->set ([
45
46
'channel ' => $ channel ,
Original file line number Diff line number Diff line change @@ -24,30 +24,29 @@ class RTDB extends Broadcaster
24
24
public function __construct ($ config )
25
25
{
26
26
$ this ->config = $ config ;
27
- $ factory = (new Factory ())
27
+ $ this -> db = (new Factory ())
28
28
->withServiceAccount (base_path ($ config ['creds_file ' ]))
29
- ->withDatabaseUri ($ config ['databaseURL ' ]);
30
-
31
- $ this ->db = $ factory ->createDatabase ();
29
+ ->withDatabaseUri ($ config ['databaseURL ' ])
30
+ ->createDatabase ();
32
31
}
33
32
34
33
/**
35
34
* {@inheritdoc}
36
35
*/
37
36
public function broadcast (array $ channels , $ event , array $ payload = [])
38
37
{
38
+ $ db = $ this ->db ->getReference ($ this ->config ['collection_name ' ]);
39
39
$ socket = Arr::pull ($ payload , 'socket ' );
40
40
41
41
foreach ($ this ->formatChannels ($ channels ) as $ channel ) {
42
42
try {
43
- $ this ->db ->getReference ($ this ->config ['collection_name ' ])
44
- ->push ([
45
- 'channel ' => $ channel ,
46
- 'data ' => $ payload ,
47
- 'event ' => $ event ,
48
- 'socket ' => $ socket ,
49
- 'timestamp ' => round (now ()->valueOf ()), // return date == to js Date.now()
50
- ]);
43
+ $ db ->push ([
44
+ 'channel ' => $ channel ,
45
+ 'data ' => $ payload ,
46
+ 'event ' => $ event ,
47
+ 'socket ' => $ socket ,
48
+ 'timestamp ' => round (now ()->valueOf ()), // return date == to js Date.now()
49
+ ]);
51
50
} catch (ApiException $ e ) {
52
51
throw new BroadcastException ($ e );
53
52
}
You can’t perform that action at this time.
0 commit comments