Skip to content

Commit

Permalink
fixed port number issue
Browse files Browse the repository at this point in the history
  • Loading branch information
ohuu committed Jul 5, 2022
1 parent a097896 commit 6196d1a
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
2 changes: 1 addition & 1 deletion local/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "local",
"version": "2.1.1",
"version": "2.1.2",
"main": "dist/main/index.cjs",
"author": "草鞋没号 <308487730@qq.com>",
"license": "MIT",
Expand Down
9 changes: 7 additions & 2 deletions local/packages/main/flows/udp/udpSink.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,12 @@ import { observerToUdp } from "../../rxadapters/rxUdp";
import { useUdpSocket } from "./useUdpSocket";

const sendingSockets: dgram.Socket[] = [];
let nextPort = 5000;
let nextPort = 5001;

export function incPort() {
console.log("Hellllooo?");
nextPort = nextPort + 1;
}

export interface UdpSinkOptions {
name: string;
Expand Down Expand Up @@ -50,7 +55,7 @@ export function udpSink(options: UdpSinkOptions): Promise<UdpSink> {

// create a new observer from the socket to observe the source
const toAddress = options.toAddress ?? "127.0.0.1";
const toPort = options.toPort ?? existingSocket ? nextPort : ++nextPort;
const toPort = options.toPort ?? nextPort;
return socket
.then((socket) => observerToUdp(toAddress, toPort, socket, options.sender, options.debug))
.then((observer) => {
Expand Down
5 changes: 4 additions & 1 deletion local/packages/main/remoteWs.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import { match } from "ts-pattern";
import { sources, sinks, connections, connectSink } from "./flows/index";
import { udpSource, udpSink } from "./flows/udp";
import { wsSource, wsSink } from "./flows/ws";
import { incPort } from "./flows/udp/udpSink";

///////////////////////////////////////////////////////////////////////////////////////////////////
// Types
Expand Down Expand Up @@ -126,6 +127,8 @@ export function newRemoteWs(

// send message to remote
.then((_) => {
incPort();

/* TODO: Implement this! */
})

Expand All @@ -142,7 +145,7 @@ export function newRemoteWs(
sinks.splice(i, 1);

console.log(`🔌 unsubscribing all flows from ${msg.from}`);
const j = connections.findIndex((conn) => conn.from === msg.from);
const j = connections.findIndex((conn) => conn.to.endsWith(msg.from));

if (j >= 0) {
connections[j].subscription.unsubscribe();
Expand Down
2 changes: 1 addition & 1 deletion local/packages/renderer/src/components/ClientTable.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<script lang="ts" setup>
import type { Ref } from "vue";
import { Ref, watchEffect } from "vue";
import type { ClientRole, ClientSummary, ClientSummaryMap } from "../../../../../shared/clients";
import { ipcRenderer } from "electron";
Expand Down
2 changes: 2 additions & 0 deletions local/packages/renderer/src/components/ClientTableCell.vue
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
<script lang="ts" setup>
import { ref, Ref } from "vue";
import { MinusIcon, PlusIcon } from "@heroicons/vue/solid";
import { remoteState } from "../remote";
const props = defineProps({
sender: {
Expand Down

0 comments on commit 6196d1a

Please sign in to comment.