Last change
on this file since fa375fe was 6a3a178, checked in by Ema <ema_spirova@…>, 3 years ago |
initial commit
|
-
Property mode
set to
100644
|
File size:
1.5 KB
|
Line | |
---|
1 | import Emitter = require("component-emitter");
|
---|
2 | /**
|
---|
3 | * Protocol version.
|
---|
4 | *
|
---|
5 | * @public
|
---|
6 | */
|
---|
7 | export declare const protocol: number;
|
---|
8 | export declare enum PacketType {
|
---|
9 | CONNECT = 0,
|
---|
10 | DISCONNECT = 1,
|
---|
11 | EVENT = 2,
|
---|
12 | ACK = 3,
|
---|
13 | CONNECT_ERROR = 4,
|
---|
14 | BINARY_EVENT = 5,
|
---|
15 | BINARY_ACK = 6
|
---|
16 | }
|
---|
17 | export interface Packet {
|
---|
18 | type: PacketType;
|
---|
19 | nsp: string;
|
---|
20 | data?: any;
|
---|
21 | id?: number;
|
---|
22 | attachments?: number;
|
---|
23 | }
|
---|
24 | /**
|
---|
25 | * A socket.io Encoder instance
|
---|
26 | */
|
---|
27 | export declare class Encoder {
|
---|
28 | /**
|
---|
29 | * Encode a packet as a single string if non-binary, or as a
|
---|
30 | * buffer sequence, depending on packet type.
|
---|
31 | *
|
---|
32 | * @param {Object} obj - packet object
|
---|
33 | */
|
---|
34 | encode(obj: Packet): any[];
|
---|
35 | /**
|
---|
36 | * Encode packet as string.
|
---|
37 | */
|
---|
38 | private encodeAsString;
|
---|
39 | /**
|
---|
40 | * Encode packet as 'buffer sequence' by removing blobs, and
|
---|
41 | * deconstructing packet into object with placeholders and
|
---|
42 | * a list of buffers.
|
---|
43 | */
|
---|
44 | private encodeAsBinary;
|
---|
45 | }
|
---|
46 | /**
|
---|
47 | * A socket.io Decoder instance
|
---|
48 | *
|
---|
49 | * @return {Object} decoder
|
---|
50 | */
|
---|
51 | export declare class Decoder extends Emitter {
|
---|
52 | private reconstructor;
|
---|
53 | constructor();
|
---|
54 | /**
|
---|
55 | * Decodes an encoded packet string into packet JSON.
|
---|
56 | *
|
---|
57 | * @param {String} obj - encoded packet
|
---|
58 | */
|
---|
59 | add(obj: any): void;
|
---|
60 | /**
|
---|
61 | * Decode a packet String (JSON data)
|
---|
62 | *
|
---|
63 | * @param {String} str
|
---|
64 | * @return {Object} packet
|
---|
65 | */
|
---|
66 | private decodeString;
|
---|
67 | private static isPayloadValid;
|
---|
68 | /**
|
---|
69 | * Deallocates a parser's resources
|
---|
70 | */
|
---|
71 | destroy(): void;
|
---|
72 | }
|
---|
Note:
See
TracBrowser
for help on using the repository browser.