agorushkin
agorushkin
DDeno
Created by agorushkin on 9/27/2024 in #help
Deno Datagram vs Node Datagram
export class PromiseSocket {
#socket: Deno.DatagramConn;

constructor() {
this.#socket = Deno.listenDatagram({
port: 0,
transport: 'udp',
});
}

send = async (
buffer: Uint8Array,
host: string,
port: number,
): Promise<Result<Uint8Array>> => {
try {
const message_buffer = await this.#send(buffer, host, port);
return pass(message_buffer);
} catch (err) {
return fail(err);
}
};

close = () => {
this.#socket.close();
};

#send = async (
buffer: Uint8Array,
host: string,
port: number,
): Promise<Uint8Array> => {
const addr = {
hostname: host,
port,
transport: 'udp',
} satisfies Deno.NetAddr;

await this.#socket.send(buffer, addr);
const [message] = await this.#socket.receive();

return message;
};
}
export class PromiseSocket {
#socket: Deno.DatagramConn;

constructor() {
this.#socket = Deno.listenDatagram({
port: 0,
transport: 'udp',
});
}

send = async (
buffer: Uint8Array,
host: string,
port: number,
): Promise<Result<Uint8Array>> => {
try {
const message_buffer = await this.#send(buffer, host, port);
return pass(message_buffer);
} catch (err) {
return fail(err);
}
};

close = () => {
this.#socket.close();
};

#send = async (
buffer: Uint8Array,
host: string,
port: number,
): Promise<Uint8Array> => {
const addr = {
hostname: host,
port,
transport: 'udp',
} satisfies Deno.NetAddr;

await this.#socket.send(buffer, addr);
const [message] = await this.#socket.receive();

return message;
};
}
Deno code
3 replies
DDeno
Created by agorushkin on 9/27/2024 in #help
Deno Datagram vs Node Datagram
Node code
3 replies
DDeno
Created by agorushkin on 9/25/2023 in #help
Deno Emit
But it does work though aye
11 replies
DDeno
Created by agorushkin on 9/25/2023 in #help
Deno Emit
Basically same as React
11 replies
DDeno
Created by agorushkin on 9/25/2023 in #help
Deno Emit
No description
11 replies
DDeno
Created by agorushkin on 9/25/2023 in #help
Deno Emit
deno bundle code is also bigger by about 100 lines or so hmm
11 replies
DDeno
Created by agorushkin on 9/25/2023 in #help
Deno Emit
No description
11 replies
DDeno
Created by agorushkin on 9/25/2023 in #help
Deno Emit
No description
11 replies
DDeno
Created by agorushkin on 6/4/2023 in #help
Deno.open() question
Alright, thank you! Yeah, that was my main concern - I always close my files manially, so I was just wondering what happens if a crash occurs
3 replies
DDeno
Created by agorushkin on 10/14/2022 in #help
How do I detect mouse clicks and key presses with Deno.stdin?
Thank you very much nontheless! Helped a quite a bit
6 replies
DDeno
Created by agorushkin on 10/25/2022 in #help
How do I render react?
I was thinking of using https://github.com/preactjs/preact-render-to-string , but I just couldn't figure out as to how to get it imported
4 replies
DDeno
Created by agorushkin on 10/14/2022 in #help
How do I detect mouse clicks and key presses with Deno.stdin?
Ah yeah, I saw that. I was just trying to figure out how it worked, but couldn't exactly pin-point it
6 replies