Preparing search index...

    Base class for network sockets, providing common send and event handling functionality.

        // BaseSocket is the base class for network sockets. Use WebSocket as a
    // concrete subclass to demonstrate connect(), close(), onConnect, onData, onError.
    const ws = WebSocket.create();
    this.socket = ws;

    this.connections.push(
    ws.onConnect.connect(() => {
    console.log('WebSocket connected');
    ws.send('hello from plugin');
    })
    );
    this.connections.push(
    ws.onData.connect((buffer: Editor.Buffer) => {
    console.log('Received data:', buffer.toString());
    })
    );
    this.connections.push(
    ws.onEnd.connect(() => {
    console.log('WebSocket connection ended');
    })
    );
    this.connections.push(
    ws.onError.connect((code: number) => {
    console.log('WebSocket error code:', code);
    })
    );

    const addr = new Address();
    addr.address = 'localhost';
    addr.port = 8080;
    ws.connect(addr);
    console.log('WebSocket connecting to', addr.address + ':' + addr.port);

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    localAddress: Address

    The local address bound to this socket.

    onConnect: signal0<void>

    Signal fired when the socket successfully establishes a connection.

    onData: signal1<Buffer, void>

    Signal fired when data is received on the socket, carrying the received buffer.

    onEnd: signal0<void>

    Signal fired when the remote end signals the end of transmission.

    onError: signal1<number, void>

    Signal fired when a socket error occurs.

    remoteAddress: Address

    The remote address this socket is connected to.

    Methods

    • Closes the socket connection gracefully.

      Returns void

    • Destroys the socket and releases all associated resources immediately.

      Returns void

    • Returns true if the object is of the specified type.

      Parameters

      • type: string

      Returns boolean