angular / angular/angularfire

Angularfire and NodeJS firebase chat application by using topics

オープン
#3,223 コメント 1 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
TypeScript
スター
7.8k
フォーク
2.2k
平均マージ
22時間 28分
マージ済み PR(30日)
6

説明

I'm a newbie on the firebase. I'm trying to make a chat application with multiple users and multiple rooms by using `AngularJS` (`angularfire`) for the frontend and `NodeJS` for the backend. I want to send many-to-many notifications. I'll use `topics` for this.

Here are the steps I followed:

1. Register user to firebase (backend-NodeJS)
2. Save user UID to the database (MongoDB)
3. Subscribe this user to the topics (backend-NodeJS)
4. Receive notifications from the topics which user has subscribed (frontend-Angular)

I can listen notifications by using `AngularFireMessaging` module (requesting permission and listening) by using these methods in my app.component.ts:

```typescript
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.scss'],
})
export class AppComponent implements OnInit {
constructor( private afMessaging: AngularFireMessaging ) { }

ngOnInit(): void {
this.requestPermission();
this.listen();
}

requestPermission() {
this.afMessaging.requestPermission
.pipe(mergeMapTo(this.afMessaging.tokenChanges))
.subscribe(
(token) => { console.log('Permission granted! Save to the server!', token); },
(error) => { console.error(error); },
);
}

listen() {
console.log('messages are being listened');
this.afMessaging.messages
.subscribe((message) => {
console.log("messages from firebase");
console.log(message);
});
}
}
```

But as I understand this just registers the token and listens it.

I know I can use realtime databases of firebase. But the app is already prepared and we're storing users' UIds in the database. Also chat rooms and users' relations are also stored in the database.

I thought I can send notifications to the `topic`s named as `roomId`s. Then I can listen these topics.

But how can I listen these topics? I have `topic`'s names, I have also users' UIds. How can I listen these topics?

Or am I missing something?

コントリビューションガイド

コントリビューションガイドを開く

調査の方向性

app.component.ts の通知フロー、特に requestPermission() と listen() から始め、続いて NodeJS のトピック購読手順と MongoDB のユーザーおよびルームの関係を確認します。既存の Angular および NodeJS アプリケーションで roomId トピックをどのように購読して受信するかを定義できれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
angularjs, mongodb, node.js, typescript
領域
backend, databases, frontend
issue の種類
機能追加
難易度
5/5
見積もり時間
1週間以上
活発さ
停滞
明瞭さ
説明が足りない
初心者へのやさしさ
20/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。