@@ -82,7 +82,8 @@ const io = new Server<
8282
8383###With oak
8484
85- You need to use the[ .handle()] ( https://github.com/oakserver/oak#handle-method ) method:
85+ You need to use the[ .handle()] ( https://github.com/oakserver/oak#handle-method )
86+ method:
8687
8788``` ts
8889import {serve }from " https://deno.land/std@0.166.0/http/server.ts" ;
@@ -92,32 +93,27 @@ import { Application } from "https://deno.land/x/oak@v11.1.0/mod.ts";
9293const app= new Application ();
9394
9495app .use ((ctx )=> {
95- ctx .response .body = " Hello World!" ;
96+ ctx .response .body = " Hello World!" ;
9697});
9798
9899const io= new Server ();
99100
100101io .on (" connection" , (socket )=> {
101- console .log (` socket ${socket .id } connected ` );
102+ console .log (` socket ${socket .id } connected ` );
102103
103- socket .emit (" hello" ," world" );
104+ socket .emit (" hello" ," world" );
104105
105- socket .on (" disconnect" , (reason )=> {
106- console .log (` socket ${socket .id } disconnected due to ${reason } ` );
107- });
106+ socket .on (" disconnect" , (reason )=> {
107+ console .log (` socket ${socket .id } disconnected due to ${reason } ` );
108+ });
108109});
109110
110111const handler= io .handler (async (req )=> {
111- const response= await app .handle (req );
112- if (response ) {
113- return response ;
114- }else {
115- return new Response (null , { status:404 });
116- }
112+ return await app .handle (req )|| new Response (null , { status:404 });
117113});
118114
119115await serve (handler , {
120- port:3000 ,
116+ port:3000 ,
121117});
122118```
123119