MCPcopy Create free account
hub / github.com/Moddable-OpenSource/moddable / constructor

Method constructor

examples/io/tcp/tlssocket/tlssocket.js:39–61  ·  view source on GitHub ↗
(options)

Source from the content-addressed store, hash-verified

37 */
38
39 constructor(options) {
40 this.#callbacks = {
41 onReadable: options.onReadable,
42 onWritable: options.onWritable,
43 onError: options.onError
44 };
45
46 this.#session = new Session({
47 serverName: options.host, // serverName for SNI. This defaults it to host. Caller can override with options.secure.serverName
48 ...options.secure,
49 protocolVersion: 0x303,
50 });
51 this.#session.initiateHandshake();
52
53 this.#socket = new options.TCP.io({
54 ...options,
55 onReadable: count => this.#onReadable(count),
56 onWritable: count => this.#onWritable(count),
57 onError: () => this.#onError()
58 });
59 this.#socket.readable =
60 this.#socket.writable = 0;
61 }
62 close() {
63 this.#socket?.close();
64 Timer.clear(this.#doRead);

Callers

nothing calls this directly

Calls 4

#onReadableMethod · 0.95
#onWritableMethod · 0.95
#onErrorMethod · 0.95
initiateHandshakeMethod · 0.45

Tested by

no test coverage detected