./xehbit.sh
./xehbit.sh
Explore posts from servers
HHono
Created by ./xehbit.sh on 8/22/2024 in #help
c.env.incoming already piped with an await?
It's an issue i've been trying to solve for a few months now, when running this example it wont print the "Hello" text to the console, however, when removing the commented line or removing the zValidator will print the "Hello" to the console. Is the c.env.incoming already being read somewhere else?
import { HttpBindings, serve } from '@hono/node-server';
import { zValidator } from '@hono/zod-validator';
import { Hono } from 'hono';
import { z } from 'zod';

const http = new Hono<{ Bindings: HttpBindings }>();

http.post('/example', zValidator('query', z.object({ name: z.string() })), async (c) => {
await new Promise<void>((resolve) => setTimeout(() => resolve(), 1)); // Removing this line prints "Hello" to the console.

c.env.incoming.pipe(process.stdout);

return c.json({ message: 'Hello, World!' }, 200);
});

serve({
fetch: http.fetch,
hostname: 'localhost',
port: 1337,
});
import { HttpBindings, serve } from '@hono/node-server';
import { zValidator } from '@hono/zod-validator';
import { Hono } from 'hono';
import { z } from 'zod';

const http = new Hono<{ Bindings: HttpBindings }>();

http.post('/example', zValidator('query', z.object({ name: z.string() })), async (c) => {
await new Promise<void>((resolve) => setTimeout(() => resolve(), 1)); // Removing this line prints "Hello" to the console.

c.env.incoming.pipe(process.stdout);

return c.json({ message: 'Hello, World!' }, 200);
});

serve({
fetch: http.fetch,
hostname: 'localhost',
port: 1337,
});
###
POST http://localhost:1337/example?name=test HTTP/1.1
content-type: application/octet-stream

Hello
###
POST http://localhost:1337/example?name=test HTTP/1.1
content-type: application/octet-stream

Hello
2 replies
CC#
Created by ./xehbit.sh on 1/5/2023 in #help
❔ PacketWriters for high performance requests over webwockets
Is there packet writer/reader that can perform efficiently with 10.000 requests per second? An example for what i;m looking for;
public void OnVoice(User user, byte[] data)
{
PacketWriter packet = new PacketWriter();
packet.UInt8(0xFE); // Voice Packet ID
packet.UInt64(UserID);
packet.BytesWithSize(data);
this.WebSocketClient.Send(packet.GetByteArray());
}
public void OnVoice(User user, byte[] data)
{
PacketWriter packet = new PacketWriter();
packet.UInt8(0xFE); // Voice Packet ID
packet.UInt64(UserID);
packet.BytesWithSize(data);
this.WebSocketClient.Send(packet.GetByteArray());
}
2 replies