Hi there! Are you looking for the official Deno documentation? Try docs.deno.com for all your Deno learning needs.

Socket

import { Socket } from "https://raw.githubusercontent.com/takker99/scrapbox-userscript-std/0.14.10/mod.ts";
class Socket<ListenEvents extends EventsMap = DefaultEventsMap, EmitEvents extends EventsMap = ListenEvents> extends StrictEventEmitter<ListenEvents, EmitEvents, SocketReservedEvents> {
constructor(
io: Manager,
nsp: string,
opts?: Partial<SocketOptions>,
);
private _anyListeners;
private ack;
private acks;
private destroy;
private emitBuffered;
private emitEvent;
private flags;
private ids;
private readonly nsp;
private onack;
private onclose;
private onconnect;
private ondisconnect;
private onerror;
private onevent;
private onopen;
private onpacket;
private packet;
private subEvents;
private subs?;
get active(): boolean;
auth: {
[key: string]: any;
}
| ((cb: (data: object) => void) => void);
connected: boolean;
disconnected: boolean;
id: string;
readonly io: Manager<ListenEvents, EmitEvents>;
receiveBuffer: Array<ReadonlyArray<any>>;
sendBuffer: Array<Packet>;
get volatile(): this;
 
close(): this;
compress(compress: boolean): this;
connect(): this;
disconnect(): this;
emit<Ev extends EventNames<EmitEvents>>(ev: Ev, ...args: EventParams<EmitEvents, Ev>): this;
listenersAny(): ((...args: any[]) => void)[];
offAny(listener?: (...args: any[]) => void): this;
onAny(listener: (...args: any[]) => void): this;
open(): this;
prependAny(listener: (...args: any[]) => void): this;
send(...args: any[]): this;
}

§Type Parameters

§
ListenEvents extends EventsMap = DefaultEventsMap
[src]
§
EmitEvents extends EventsMap = ListenEvents
[src]

§Extends

§
StrictEventEmitter<ListenEvents, EmitEvents, SocketReservedEvents>
[src]

§Constructors

§
new Socket(io: Manager, nsp: string, opts?: Partial<SocketOptions>)
[src]

Socket constructor.

§Properties

§
_anyListeners
[src]
§

Produces an ack callback to emit with an event.

§
destroy
[src]

Called upon forced client/server side disconnections, this method ensures the manager stops tracking us and that reconnections don't get triggered for this.

§
emitBuffered
[src]

Emit buffered events (received and emitted).

§
emitEvent
[src]
§
flags
[src]
§
onack
[src]

Called upon a server acknowlegement.

§
onclose
[src]

Called upon engine close.

§
onconnect
[src]

Called upon server connect.

§
ondisconnect
[src]

Called upon server disconnect.

§
onerror
[src]

Called upon engine or manager error.

§
onevent
[src]

Called upon a server event.

§
onopen
[src]

Called upon engine open.

§
onpacket
[src]

Called with socket packet.

§
packet
[src]

Sends a packet.

§
subEvents
[src]

Subscribe to open, close and packet events

§
active: boolean readonly
[src]

Whether the Socket will try to reconnect when its Manager connects or reconnects

§
auth: {
[key: string]: any;
}
| ((cb: (data: object) => void) => void)
[src]
§
connected: boolean
[src]
§
disconnected: boolean
[src]
§
id: string
[src]
§
io: Manager<ListenEvents, EmitEvents>
[src]
§
receiveBuffer: Array<ReadonlyArray<any>>
[src]
§
sendBuffer: Array<Packet>
[src]
§
volatile: this readonly
[src]

Sets a modifier for a subsequent event emission that the event message will be dropped when this socket is not ready to send messages.

§Methods

§
close(): this
[src]

Alias for disconnect()

@return

self

§
compress(compress: boolean): this
[src]

Sets the compress flag.

@param compress
  • if true, compresses the sending data
@return

self

§
connect(): this
[src]

"Opens" the socket.

§
disconnect(): this
[src]

Disconnects the socket manually.

@return

self

§
emit<Ev extends EventNames<EmitEvents>>(ev: Ev, ...args: EventParams<EmitEvents, Ev>): this
[src]

Override emit. If the event is in events, it's emitted normally.

@return

self

§
listenersAny(): ((...args: any[]) => void)[]
[src]

Returns an array of listeners that are listening for any event that is specified. This array can be manipulated, e.g. to remove listeners.

§
offAny(listener?: (...args: any[]) => void): this
[src]

Removes the listener that will be fired when any event is emitted.

@param listener
§
onAny(listener: (...args: any[]) => void): this
[src]

Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the callback.

@param listener
§
open(): this
[src]

Alias for connect()

§
prependAny(listener: (...args: any[]) => void): this
[src]

Adds a listener that will be fired when any event is emitted. The event name is passed as the first argument to the callback. The listener is added to the beginning of the listeners array.

@param listener
§
send(...args: any[]): this
[src]

Sends a message event.

@return

self