add most of the client connection protocol

This commit is contained in:
CoolElectronics 2023-08-11 19:07:22 -04:00
parent ea17f5d71c
commit 9ef8cc4cea
No known key found for this signature in database
GPG key ID: F63593D168636C50
6 changed files with 769 additions and 123 deletions

25
client/AdriftClient.ts Normal file
View file

@ -0,0 +1,25 @@
import Connection from "./Connection";
import { BareClient as BareClientCustom, registerRemoteListener, setBareClientImplementation, Client, GetRequestHeadersCallback, MetaCallback, ReadyStateCallback, WebSocketImpl, BareHeaders, BareResponse } from "bare-client-custom";
// export class Adrift {
// bareclient:AdriftBareClient,
// constructor(connection:Connection){
//
// }
// }
//
export class AdriftBareClient extends Client {
constructor(private connection: Connection) {
super();
}
async request(method: string, requestHeaders: BareHeaders, body: BodyInit | null, remote: URL, cache: string | undefined, duplex: string | undefined, signal: AbortSignal | undefined): Promise<BareResponse> {
let rawResponse = await this.connection.httprequest({ a: "test data" });
return new Response(JSON.stringify(rawResponse)) as BareResponse;
}
async connect(remote: URL, protocols: string[], getRequestHeaders: GetRequestHeadersCallback, onMeta: MetaCallback, onReadyState: ReadyStateCallback, webSocketImpl: WebSocketImpl): WebSocket {
}
}