Skip to content

Commit 50a8e2e

Browse files
committed
update examples
1 parent e99217e commit 50a8e2e

File tree

4 files changed

+21
-23
lines changed

4 files changed

+21
-23
lines changed

engine/mod.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
export * from "./mixer.ts";
22
export * as Engine from "./mixer.ts";
33
export * as EngineLib from "./mixer.ts";
4+
export * as default from "./mixer.ts";
45

56
// declerations
67

example.ts

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
1-
import Engine from "./engine.ts";
2-
import "./docs.d.ts";
3-
4-
const engine: Engine=new Engine();
5-
engine.port=80;
6-
engine.host="0.0.0.0";
7-
engine.upgrade=true;
8-
engine.on("connect",async function({socket,client}: HttpSocket): Promise<void>{
1+
import Engine from "./engine/mod.ts";
2+
const engine=Engine;
3+
4+
5+
engine.on("connect",async function({socket,client}: Engine.HttpSocket): Promise<void>{
96
console.log(client);
107

8+
if(!client)return;
9+
1110
if(!client.isValid){
1211
socket.status=400;
1312
socket.statusMessage="Bad Request";
@@ -31,11 +30,11 @@ engine.on("connect",async function({socket,client}: HttpSocket): Promise<void>{
3130
}
3231
});
3332
engine.on("http2",h2cHandler);
34-
async function h2cHandler(h2c:Http2Socket){
33+
async function h2cHandler(h2c:Engine.Http2Socket){
3534
let r=await h2c.ready;
3635
console.log("h2c",r);
3736
h2c.on("error",console.error);
38-
h2c.on("stream",async function(stream:Http2Stream){
37+
h2c.on("stream",async function(stream:Engine.Http2Stream){
3938
console.log(stream);
4039

4140
//stream.status=200;
@@ -45,7 +44,7 @@ async function h2cHandler(h2c:Http2Socket){
4544
h2c.on("close",c=>console.warn(c));
4645
}
4746
engine.on("error",console.error);
48-
engine.start();
47+
engine.start(8080);
4948
console.log("listening");
5049

5150
globalThis.engine=engine;

example2.ts

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,10 @@
1-
import Engine from "./engine.ts";
2-
import "./docs.d.ts";
1+
import Engine from "./engine/mod.ts";
2+
const engine=Engine;
33

4-
const engine: Engine=new Engine();
5-
engine.port=80;
6-
engine.host="0.0.0.0";
7-
engine.upgrade=true;
8-
engine.on("connect",async function({socket,client}: HttpSocket): Promise<void>{
4+
5+
engine.on("connect",async function({socket,client}: Engine.HttpSocket): Promise<void>{
96
console.log(client);
7+
if(!client)return;
108

119
if(!client.isValid){
1210
socket.status=400;
@@ -29,22 +27,22 @@ engine.on("connect",async function({socket,client}: HttpSocket): Promise<void>{
2927
}
3028
});
3129
engine.on("http2",h2cHandler);
32-
async function handler(sock:HttpSocket|PseudoHttpSocket){
30+
async function handler(sock:Engine.HttpSocket|Engine.PseudoHttpSocket){
3331
sock.setHeader("Content-Type","text/plain");
3432
sock.close(JSON.stringify(sock.client));
3533
};
36-
async function h2cHandler(socket: Http2Socket){
34+
async function h2cHandler(socket: Engine.Http2Socket){
3735
socket.on("error",console.error);
3836
await socket.ready;
3937
console.log("http2");
40-
socket.on("stream",async function(stream:Http2Stream){
38+
socket.on("stream",async function(stream:Engine.Http2Stream){
4139
console.log("http2 stream");
4240
const ps=stream.pseudo();
4341
handler(ps);
4442
})
4543
};
4644
engine.on("error",console.error);
47-
engine.start();
45+
engine.start(8080);
4846
console.log("listening");
4947

5048
globalThis.engine=engine;

last-pid.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
15356
1+
5808

0 commit comments

Comments
 (0)