mirror of
https://github.com/logos-messaging/examples.waku.org.git
synced 2026-01-05 22:33:08 +00:00
chore(relay-angular-chat): bump js-waku to 0.29.0
This commit is contained in:
parent
9b3093bee4
commit
55d8f7ebc4
@ -21,7 +21,7 @@
|
|||||||
"@angular/platform-browser": "~14.2.0",
|
"@angular/platform-browser": "~14.2.0",
|
||||||
"@angular/platform-browser-dynamic": "~14.2.0",
|
"@angular/platform-browser-dynamic": "~14.2.0",
|
||||||
"@angular/router": "~14.2.0",
|
"@angular/router": "~14.2.0",
|
||||||
"js-waku": "0.28.1",
|
"js-waku": "0.29.0",
|
||||||
"protobufjs": "^7.1.0",
|
"protobufjs": "^7.1.0",
|
||||||
"rxjs": "~7.5.0",
|
"rxjs": "~7.5.0",
|
||||||
"tslib": "^2.3.0",
|
"tslib": "^2.3.0",
|
||||||
|
|||||||
8
relay-angular-chat/pnpm-lock.yaml
generated
8
relay-angular-chat/pnpm-lock.yaml
generated
@ -16,7 +16,7 @@ specifiers:
|
|||||||
'@types/node': ^17.0.21
|
'@types/node': ^17.0.21
|
||||||
is-ci-cli: ^2.2.0
|
is-ci-cli: ^2.2.0
|
||||||
jasmine-core: ~4.3.0
|
jasmine-core: ~4.3.0
|
||||||
js-waku: 0.28.1
|
js-waku: 0.29.0
|
||||||
karma: ~6.4.0
|
karma: ~6.4.0
|
||||||
karma-chrome-launcher: ~3.1.0
|
karma-chrome-launcher: ~3.1.0
|
||||||
karma-coverage: ~2.2.0
|
karma-coverage: ~2.2.0
|
||||||
@ -37,7 +37,7 @@ dependencies:
|
|||||||
'@angular/platform-browser': 14.2.0_afytwol7hs4qio34buyx2grhfa
|
'@angular/platform-browser': 14.2.0_afytwol7hs4qio34buyx2grhfa
|
||||||
'@angular/platform-browser-dynamic': 14.2.0_owch6soaoexeadly32xw5vendq
|
'@angular/platform-browser-dynamic': 14.2.0_owch6soaoexeadly32xw5vendq
|
||||||
'@angular/router': 14.2.0_6lk4yxyxfaqzosenawf2bqx6vy
|
'@angular/router': 14.2.0_6lk4yxyxfaqzosenawf2bqx6vy
|
||||||
js-waku: 0.28.1
|
js-waku: 0.29.0
|
||||||
protobufjs: 7.1.0
|
protobufjs: 7.1.0
|
||||||
rxjs: 7.5.6
|
rxjs: 7.5.6
|
||||||
tslib: 2.4.0
|
tslib: 2.4.0
|
||||||
@ -5440,8 +5440,8 @@ packages:
|
|||||||
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
|
resolution: {integrity: sha512-RdJUflcE3cUzKiMqQgsCu06FPu9UdIJO0beYbPhHN4k6apgJtifcoCtT9bcxOpYBtpD2kCM6Sbzg4CausW/PKQ==}
|
||||||
dev: true
|
dev: true
|
||||||
|
|
||||||
/js-waku/0.28.1:
|
/js-waku/0.29.0:
|
||||||
resolution: {integrity: sha512-0h9TpV6jywyjdes8hr9tFV/5iJh3LQN3sQFYHcXyi4cK+4htNiMrCRjBSqRBtfhs/j+4tOkrht8gRJRLHdA5RA==}
|
resolution: {integrity: sha512-44GOpNbkFt/1/bDZ3tcaeemehaZaxw404QmTvHw7FUwY6dtvGsDEERLEw1TERUljDESFjvEOcJjYnLcNDY1MHg==}
|
||||||
engines: {node: '>=16'}
|
engines: {node: '>=16'}
|
||||||
dependencies:
|
dependencies:
|
||||||
'@chainsafe/libp2p-gossipsub': 4.1.1
|
'@chainsafe/libp2p-gossipsub': 4.1.1
|
||||||
|
|||||||
@ -1,8 +1,9 @@
|
|||||||
import { Component, OnInit } from "@angular/core";
|
import { Component, OnInit } from "@angular/core";
|
||||||
import { WakuService } from "../waku.service";
|
import { WakuService } from "../waku.service";
|
||||||
import { WakuMessage } from "js-waku";
|
|
||||||
import type { WakuPrivacy } from "js-waku/lib/interfaces";
|
import type { WakuPrivacy } from "js-waku/lib/interfaces";
|
||||||
import protobuf from "protobufjs";
|
import protobuf from "protobufjs";
|
||||||
|
import { DecoderV0, EncoderV0 } from "js-waku/lib/waku_message/version_0";
|
||||||
|
import type { MessageV0 } from "js-waku/lib/waku_message/version_0";
|
||||||
|
|
||||||
const ProtoChatMessage = new protobuf.Type("ChatMessage")
|
const ProtoChatMessage = new protobuf.Type("ChatMessage")
|
||||||
.add(new protobuf.Field("timestamp", 1, "uint32"))
|
.add(new protobuf.Field("timestamp", 1, "uint32"))
|
||||||
@ -20,13 +21,18 @@ interface MessageInterface {
|
|||||||
})
|
})
|
||||||
export class MessagesComponent implements OnInit {
|
export class MessagesComponent implements OnInit {
|
||||||
contentTopic: string = `/js-waku-examples/1/chat/proto`;
|
contentTopic: string = `/js-waku-examples/1/chat/proto`;
|
||||||
|
decoder: DecoderV0;
|
||||||
|
encoder: EncoderV0;
|
||||||
messages: MessageInterface[] = [];
|
messages: MessageInterface[] = [];
|
||||||
messageCount: number = 0;
|
messageCount: number = 0;
|
||||||
waku!: WakuPrivacy;
|
waku!: WakuPrivacy;
|
||||||
wakuStatus!: string;
|
wakuStatus!: string;
|
||||||
deleteObserver?: () => void;
|
deleteObserver?: () => void;
|
||||||
|
|
||||||
constructor(private wakuService: WakuService) {}
|
constructor(private wakuService: WakuService) {
|
||||||
|
this.decoder = new DecoderV0(this.contentTopic);
|
||||||
|
this.encoder = new EncoderV0(this.contentTopic);
|
||||||
|
}
|
||||||
|
|
||||||
ngOnInit(): void {
|
ngOnInit(): void {
|
||||||
this.wakuService.wakuStatus.subscribe((wakuStatus) => {
|
this.wakuService.wakuStatus.subscribe((wakuStatus) => {
|
||||||
@ -36,8 +42,8 @@ export class MessagesComponent implements OnInit {
|
|||||||
this.wakuService.waku.subscribe((waku) => {
|
this.wakuService.waku.subscribe((waku) => {
|
||||||
this.waku = waku;
|
this.waku = waku;
|
||||||
this.deleteObserver = this.waku.relay.addObserver(
|
this.deleteObserver = this.waku.relay.addObserver(
|
||||||
this.processIncomingMessages,
|
this.decoder,
|
||||||
[this.contentTopic]
|
this.processIncomingMessages
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -57,16 +63,13 @@ export class MessagesComponent implements OnInit {
|
|||||||
});
|
});
|
||||||
|
|
||||||
const payload = ProtoChatMessage.encode(protoMsg).finish();
|
const payload = ProtoChatMessage.encode(protoMsg).finish();
|
||||||
|
this.waku.relay.send(this.encoder, { payload }).then(() => {
|
||||||
WakuMessage.fromBytes(payload, this.contentTopic).then((wakuMessage) => {
|
console.log(`Message #${this.messageCount} sent`);
|
||||||
this.waku.relay.send(wakuMessage).then(() => {
|
this.messageCount += 1;
|
||||||
console.log(`Message #${this.messageCount} sent`);
|
|
||||||
this.messageCount += 1;
|
|
||||||
});
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
processIncomingMessages = (wakuMessage: WakuMessage) => {
|
processIncomingMessages = (wakuMessage: MessageV0) => {
|
||||||
if (!wakuMessage.payload) return;
|
if (!wakuMessage.payload) return;
|
||||||
|
|
||||||
const { text, timestamp } = ProtoChatMessage.decode(
|
const { text, timestamp } = ProtoChatMessage.decode(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user