mirror of
https://github.com/coder/code-server.git
synced 2024-12-27 19:56:57 +03:00
a328204d80
* Implements the fs module * Add stats object * Add not implemented to createWriteStream * Update mkdtemp to use tmp dir * Unexport Stats * Add client web socket for commands and restructure
29 lines
682 B
TypeScript
29 lines
682 B
TypeScript
import { Emitter } from "@coder/events";
|
|
import { Client } from "../src/browser/client";
|
|
import { Server } from "../src/node/server";
|
|
|
|
export const createClient = (): Client => {
|
|
const s2c = new Emitter<Uint8Array | Buffer>();
|
|
const c2s = new Emitter<Uint8Array | Buffer>();
|
|
|
|
new Server({
|
|
close: () => undefined,
|
|
onClose: () => undefined,
|
|
onMessage: (cb) => {
|
|
c2s.event((d) => cb(d));
|
|
},
|
|
send: (data) => setTimeout(() => s2c.emit(data), 0),
|
|
});
|
|
|
|
const client = new Client({
|
|
close: () => undefined,
|
|
onClose: () => undefined,
|
|
onMessage: (cb) => {
|
|
s2c.event((d) => cb(d));
|
|
},
|
|
send: (data) => setTimeout(() => c2s.emit(data), 0),
|
|
});
|
|
|
|
return client;
|
|
};
|