-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathezy-constants.js
111 lines (101 loc) · 4 KB
/
ezy-constants.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
export const EzyCommand = {
ERROR: { id: 10, name: 'ERROR' },
HANDSHAKE: { id: 11, name: 'HANDSHAKE' },
PING: { id: 12, name: 'PING' },
PONG: { id: 13, name: 'PONG' },
DISCONNECT: { id: 14, name: 'DISCONNECT' },
LOGIN: { id: 20, name: 'LOGIN' },
LOGIN_ERROR: { id: 21, name: 'LOGIN_ERROR' },
LOGOUT: { id: 22, name: 'LOGOUT' },
APP_ACCESS: { id: 30, name: 'APP_ACCESS' },
APP_REQUEST: { id: 31, name: 'APP_REQUEST' },
APP_EXIT: { id: 33, name: 'APP_EXIT' },
APP_ACCESS_ERROR: { id: 34, name: 'APP_ACCESS_ERROR' },
APP_REQUEST_ERROR: { id: 35, name: 'APP_REQUEST_ERROR' },
PLUGIN_INFO: { id: 40, name: 'PLUGIN_INFO' },
PLUGIN_REQUEST: { id: 41, name: 'PLUGIN_REQUEST' },
};
export var EzyCommands = EzyCommands || {};
EzyCommands[EzyCommand.ERROR.id] = EzyCommand.ERROR;
EzyCommands[EzyCommand.HANDSHAKE.id] = EzyCommand.HANDSHAKE;
EzyCommands[EzyCommand.PING.id] = EzyCommand.PING;
EzyCommands[EzyCommand.PONG.id] = EzyCommand.PONG;
EzyCommands[EzyCommand.DISCONNECT.id] = EzyCommand.DISCONNECT;
EzyCommands[EzyCommand.LOGIN.id] = EzyCommand.LOGIN;
EzyCommands[EzyCommand.LOGIN_ERROR.id] = EzyCommand.LOGIN_ERROR;
EzyCommands[EzyCommand.LOGOUT.id] = EzyCommand.LOGOUT;
EzyCommands[EzyCommand.APP_ACCESS.id] = EzyCommand.APP_ACCESS;
EzyCommands[EzyCommand.APP_REQUEST.id] = EzyCommand.APP_REQUEST;
EzyCommands[EzyCommand.APP_EXIT.id] = EzyCommand.APP_EXIT;
EzyCommands[EzyCommand.APP_ACCESS_ERROR.id] = EzyCommand.APP_ACCESS_ERROR;
EzyCommands[EzyCommand.APP_REQUEST_ERROR.id] = EzyCommand.APP_REQUEST_ERROR;
EzyCommands[EzyCommand.PLUGIN_INFO.id] = EzyCommand.PLUGIN_INFO;
EzyCommands[EzyCommand.PLUGIN_REQUEST.id] = EzyCommand.PLUGIN_REQUEST;
Object.freeze(EzyCommands);
export const EzyEventType = {
CONNECTION_SUCCESS: 'CONNECTION_SUCCESS',
CONNECTION_FAILURE: 'CONNECTION_FAILURE',
DISCONNECTION: 'DISCONNECTION',
LOST_PING: 'LOST_PING',
TRY_CONNECT: 'TRY_CONNECT',
};
export const EzyConnectionStatus = {
NULL: 'NULL',
CONNECTING: 'CONNECTING',
CONNECTED: 'CONNECTED',
DISCONNECTED: 'DISCONNECTED',
FAILURE: 'FAILURE',
RECONNECTING: 'RECONNECTING',
};
export const EzyConnectionFailedReason = {
NETWORK_UNREACHABLE: 'NETWORK_UNREACHABLE',
UNKNOWN_HOST: 'UNKNOWN_HOST',
CONNECTION_REFUSED: 'CONNECTION_REFUSED',
UNKNOWN: 'UNKNOWN',
};
export const EzyDisconnectReason = {
CLOSE: -1,
UNKNOWN: 0,
IDLE: 1,
NOT_LOGGED_IN: 2,
ANOTHER_SESSION_LOGIN: 3,
ADMIN_BAN: 4,
ADMIN_KICK: 5,
MAX_REQUEST_PER_SECOND: 6,
MAX_REQUEST_SIZE: 7,
SERVER_ERROR: 8,
SERVER_NOT_RESPONDING: 400,
UNAUTHORIZED: 401,
};
export var EzyDisconnectReasonNames = EzyDisconnectReasonNames || {};
EzyDisconnectReasonNames[EzyDisconnectReason.CLOSE] = 'CLOSE';
EzyDisconnectReasonNames[EzyDisconnectReason.UNKNOWN] = 'UNKNOWN';
EzyDisconnectReasonNames[EzyDisconnectReason.IDLE] = 'IDLE';
EzyDisconnectReasonNames[EzyDisconnectReason.NOT_LOGGED_IN] = 'NOT_LOGGED_IN';
EzyDisconnectReasonNames[EzyDisconnectReason.ANOTHER_SESSION_LOGIN] =
'ANOTHER_SESSION_LOGIN';
EzyDisconnectReasonNames[EzyDisconnectReason.ADMIN_BAN] = 'ADMIN_BAN';
EzyDisconnectReasonNames[EzyDisconnectReason.ADMIN_KICK] = 'ADMIN_KICK';
EzyDisconnectReasonNames[EzyDisconnectReason.MAX_REQUEST_PER_SECOND] =
'MAX_REQUEST_PER_SECOND';
EzyDisconnectReasonNames[EzyDisconnectReason.MAX_REQUEST_SIZE] =
'MAX_REQUEST_SIZE';
EzyDisconnectReasonNames[EzyDisconnectReason.SERVER_ERROR] = 'SERVER_ERROR';
EzyDisconnectReasonNames[EzyDisconnectReason.SERVER_NOT_RESPONDING] =
'SERVER_NOT_RESPONSE';
EzyDisconnectReasonNames[EzyDisconnectReason.UNAUTHORIZED] = 'UNAUTHORIZED';
EzyDisconnectReasonNames.parse = function (reasonId) {
const answer = EzyDisconnectReasonNames[reasonId];
if (answer) return answer;
return reasonId.toString();
};
Object.freeze(EzyDisconnectReasonNames);
export default {
EzyCommand,
EzyCommands,
EzyEventType,
EzyConnectionStatus,
EzyConnectionFailedReason,
EzyDisconnectReason,
EzyDisconnectReasonNames,
};