Skip to content

Commit

Permalink
fix: workflows
Browse files Browse the repository at this point in the history
  • Loading branch information
xiaohaodu committed Jul 27, 2024
1 parent dddc3ca commit 3e5dc66
Show file tree
Hide file tree
Showing 12 changed files with 88 additions and 64 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/deploy.relay_server.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ jobs:
- uses: pnpm/[email protected]
name: Install pnpm
with:
version: 9.1.3
version: 9.3.0
run_install: false
- name: Install npm dependencies
run: pnpm install
Expand All @@ -31,6 +31,6 @@ jobs:
SSH_PRIVATE_KEY: ${{ vars.SSH_KEY }}
ARGS: "-rltgoDzvO --delete"
SOURCE: "packages/web-chat-x-express/build/"
REMOTE_HOST: "81.68.108.130"
REMOTE_HOST: "182.92.222.231"
REMOTE_USER: root
TARGET: "/home/web-chat-x/web-chat-x-express"
2 changes: 1 addition & 1 deletion .github/workflows/deploy.web.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@ jobs:
SSH_PRIVATE_KEY: ${{ vars.SSH_KEY }}
ARGS: "-rltgoDzvO --delete"
SOURCE: "packages/web-chat-x-vue/dist/"
REMOTE_HOST: "81.68.108.130"
REMOTE_HOST: "182.92.222.231"
REMOTE_USER: root
TARGET: "/home/web-chat-x/web-chat-x-vue"
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@
"license": "ISC",
"engines": {
"node": "=18.18.1",
"pnpm": "=9.1.3"
"pnpm": "=9.3.0"
},
"workspaces": [
"packages/*"
Expand Down
115 changes: 58 additions & 57 deletions packages/web-chat-x-express/src/controllers/libp2p.ts
Original file line number Diff line number Diff line change
Expand Up @@ -104,63 +104,64 @@ export default class Libp2pManager {
peerId: peerId,
});
}
private handleListenEvent() {
this.libp2p.addEventListener("connection:open", (connection) => {
console.log("connection:open", connection.detail);
});
this.libp2p.addEventListener("connection:close", (connection) => {
console.log("connection:open", connection.detail);
});
this.libp2p.addEventListener("connection:prune", (connection) => {
console.log("connection:prune", connection.detail);
});
this.libp2p.addEventListener("peer:connect", (peerId) => {
console.log("peer:connect ", peerId.detail);
});
this.libp2p.addEventListener("peer:disconnect", (peerId) => {
console.log("peer:disconnect ", peerId.detail);
});
this.libp2p.addEventListener("peer:discovery", (peerIdInfo) => {
console.log("peer:discovery ", peerIdInfo.detail);
});

this.libp2p.addEventListener("peer:identify", (identifyResult) => {
console.log("peer:identify ", identifyResult.detail);
});
this.libp2p.addEventListener("peer:update", (peerUpdate) => {
console.log("peer:update ", peerUpdate.detail);
});
this.libp2p.addEventListener("self:peer:update", (peerUpdate) => {
console.log("self:peer:update ", peerUpdate.detail);
console.log("self:peer:update protocols", this.libp2p.getProtocols());
console.log("self:peer:update multiaddrs", this.libp2p.getMultiaddrs());
this.libp2p.getMultiaddrs().forEach((multiaddr, index) => {
console.log(
`self:peer:update multiaddr ${index} ${multiaddr.toString()}`
);
});
console.log("self:peer:update dialQueue", this.libp2p.getDialQueue());
console.log("self:peer:update connections", this.libp2p.getConnections());
console.log("self:peer:update peers", this.libp2p.getPeers());
});
this.libp2p.addEventListener("start", () => {
console.log("start");
console.log("protocols", this.libp2p.getProtocols());
console.log("multiaddrs", this.libp2p.getMultiaddrs());
console.log("dialQueue", this.libp2p.getDialQueue());
console.log("connections", this.libp2p.getConnections());
console.log("peers", this.libp2p.getPeers());
});
this.libp2p.addEventListener("stop", () => {
console.log("stop");
});
this.libp2p.addEventListener("transport:close", (listener) => {
console.log("transport:close", listener.detail);
});
this.libp2p.addEventListener("transport:listening", (listener) => {
console.log("transport:listening", listener.detail);
});
}
// private handleListenEvent() {
// this.libp2p.addEventListener("connection:open", (connection) => {
// console.log("connection:open", connection.detail);
// });
// this.libp2p.addEventListener("connection:close", (connection) => {
// console.log("connection:open", connection.detail);
// });
// this.libp2p.addEventListener("connection:prune", (connection) => {
// console.log("connection:prune", connection.detail);
// });
// this.libp2p.addEventListener("peer:connect", (peerId) => {
// console.log("peer:connect ", peerId.detail);
// });
// this.libp2p.addEventListener("peer:disconnect", (peerId) => {
// console.log("peer:disconnect ", peerId.detail);
// });
// this.libp2p.addEventListener("peer:discovery", (peerIdInfo) => {
// console.log("peer:discovery ", peerIdInfo.detail);
// });

// this.libp2p.addEventListener("peer:identify", (identifyResult) => {
// console.log("peer:identify ", identifyResult.detail);
// });
// this.libp2p.addEventListener("peer:update", (peerUpdate) => {
// console.log("peer:update ", peerUpdate.detail);
// });
// this.libp2p.addEventListener("self:peer:update", (peerUpdate) => {
// console.log("self:peer:update ", peerUpdate.detail);
// console.log("self:peer:update protocols", this.libp2p.getProtocols());
// console.log("self:peer:update multiaddrs", this.libp2p.getMultiaddrs());
// this.libp2p.getMultiaddrs().forEach((multiaddr, index) => {
// console.log(
// `self:peer:update multiaddr ${index} ${multiaddr.toString()}`
// );
// });
// console.log("self:peer:update dialQueue", this.libp2p.getDialQueue());
// console.log("self:peer:update connections", this.libp2p.getConnections());
// console.log("self:peer:update peers", this.libp2p.getPeers());
// });
// this.libp2p.addEventListener("start", () => {
// console.log("start");
// console.log("protocols", this.libp2p.getProtocols());
// console.log("multiaddrs", this.libp2p.getMultiaddrs());
// console.log("dialQueue", this.libp2p.getDialQueue());
// console.log("connections", this.libp2p.getConnections());
// console.log("peers", this.libp2p.getPeers());
// });
// this.libp2p.addEventListener("stop", () => {
// console.log("stop");
// });
// this.libp2p.addEventListener("transport:close", (listener) => {
// console.log("transport:close", listener.detail);
// });
// this.libp2p.addEventListener("transport:listening", (listener) => {
// console.log("transport:listening", listener.detail);
// });
// }

private handleProtocol() {}
/**
Expand All @@ -185,7 +186,7 @@ export default class Libp2pManager {
(this.libp2p.services.lanDHT as KadDHT).setMode("server");
// 获取 Relay 节点的监听地址,并确保找到一个 IPv4 地址
const listenMultiaddr = this.libp2p.getMultiaddrs();
this.handleListenEvent();
// this.handleListenEvent();
this.handleProtocol();
console.log("Relay service started on:");
listenMultiaddr.forEach((addr) => {
Expand Down
6 changes: 6 additions & 0 deletions packages/web-chat-x-vue/src/classes/Libp2pManager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,12 @@ import ChatChannel from "./ChatChannel";
import { base64ToFile, fileToBase64, getPeerIdFromUserId } from "@/utils";
import { bootstrap } from "@libp2p/bootstrap";
import { Peer } from "@libp2p/interface";
import {
ElButton,
ElMessage,
ElMessageBox,
ElNotification,
} from "element-plus";
const topics = [
`webChatX._peer-discovery._p2p._pubsub`, // It's recommended but not required to extend the global space
];
Expand Down
1 change: 1 addition & 0 deletions packages/web-chat-x-vue/src/classes/PeerManager.ts
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import { ElMessage } from "element-plus";
import Peer, { DataConnection, MediaConnection } from "peerjs";
type PeerManagerOption = {
nearPeerId: string;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,12 @@
</template>

<script setup lang="ts">
import { UploadUserFile } from "element-plus";
import {
ElButton,
ElMessage,
ElMessageBox,
UploadUserFile,
} from "element-plus";
import useDexie from "@/hooks/useDexie";
import { cloneDeep } from "lodash-es";
import useLibp2p from "@/hooks/useLibp2p";
Expand Down
7 changes: 7 additions & 0 deletions packages/web-chat-x-vue/src/types/env.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare module "*.vue" {
import type { DefineComponent } from "vue";

const vueComponent: DefineComponent<{}, {}, any>;

export default vueComponent;
}
2 changes: 1 addition & 1 deletion packages/web-chat-x-vue/src/views/Channel.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<script lang="ts" setup>
import { useRoute } from "vue-router";
import { ElMain } from "element-plus";
import { ElMain, ElMessage } from "element-plus";
import useLibp2p from "@/hooks/useLibp2p";
import EmojiComponent from "@/components/EmojiComponent.vue";
import fileIcon from '@/assets/file.svg'
Expand Down
1 change: 1 addition & 0 deletions packages/web-chat-x-vue/src/views/Homepage.vue
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,7 @@
<script setup lang="ts">
import useLibp2p from "@/hooks/useLibp2p";
const { libp2pManager } = useLibp2p();
import { ElMessage } from "element-plus";
const user = libp2pManager.getChatUser();
async function copyID() {
await navigator.clipboard.writeText(user.value.userId);
Expand Down
3 changes: 3 additions & 0 deletions packages/web-chat-x-vue/src/views/Login.vue
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,9 @@ import {
UploadProps,
UploadFile,
UploadFiles,
ElMessageBox,
ElButton,
ElMessage,
} from "element-plus";
import ChatUser from "@/classes/ChatUser";
import useLibp2p from "@/hooks/useLibp2p";
Expand Down
2 changes: 1 addition & 1 deletion packages/web-chat-x-vue/src/views/PrivateChat.vue
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@
<script lang="ts" setup>
import { useRoute } from "vue-router";
import { ElMain, ElUpload, UploadProps, UploadUserFile } from "element-plus";
import { ElMain, ElMessage, ElUpload, UploadProps, UploadUserFile } from "element-plus";
import useLibp2p from "@/hooks/useLibp2p";
import EmojiComponent from "@/components/EmojiComponent.vue";
import fileIcon from '@/assets/file.svg'
Expand Down

0 comments on commit 3e5dc66

Please sign in to comment.