Skip to content

Commit

Permalink
test: test websocket
Browse files Browse the repository at this point in the history
  • Loading branch information
wushuangs committed Sep 29, 2024
1 parent c6b98d1 commit f2336e2
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/workflows/update-frontend.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ on:
push:
branches:
- "main"
- "fix/download_loading"

tags:
- 'v*'
Expand Down
2 changes: 2 additions & 0 deletions .github/workflows/update-server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,8 @@ on:
push:
branches:
- "main"
- "fix/download_loading"

tags:
- 'v*'

Expand Down
6 changes: 6 additions & 0 deletions packages/frontend/src/stores/websocketStore.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,10 @@ export const useSocketStore = defineStore('counter', {

actions: {
start() {
console.log('process ws_url', process.env.WS_URL);

let ws_url = process.env.WS_URL || window.location.origin + '/ws';
console.log('start ws_url', ws_url);

if (ws_url.startsWith('http://')) {
ws_url = ws_url.substring(7);
Expand All @@ -43,6 +46,8 @@ export const useSocketStore = defineStore('counter', {
ws_url = 'wss://' + ws_url;
}

console.log('ws_url', ws_url);

this.websocket = new WebSocketBean({
url: ws_url,
needReconnect: true,
Expand All @@ -61,6 +66,7 @@ export const useSocketStore = defineStore('counter', {
onmessage: (ev) => {
try {
const message = JSON.parse(ev.data);
console.log('message', message);

if (message.topic == MessageTopic.Data) {
if (message.event == 'updateConfig') {
Expand Down
2 changes: 2 additions & 0 deletions packages/server2/src/app.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ export class AppController {

const payload = event.data.data.payload;

this.logger.debug('payload', JSON.stringify(payload));

broadcastWebsocketMessage({
event: 'app_installation_event',
// data: event.data.data,
Expand Down
1 change: 1 addition & 0 deletions packages/server2/src/websocketClient.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ export async function broadcastWebsocketMessage(
): Promise<WebSocketSendResult | undefined> {
try {
const users = await getWSConnectionList();
console.log('ws user', users);
console.log('ws user.lenght', users.length);
if (users.length == 0) {
return undefined;
Expand Down

0 comments on commit f2336e2

Please sign in to comment.