iosignal 2.2.1 → 3.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +248 -114
- package/dist/io.d.ts +481 -0
- package/dist/io.js +4 -5
- package/dist/io.js.map +1 -1
- package/dist/io.min.js +4 -5
- package/dist/io.min.js.map +1 -1
- package/dist/iosignal.js +9559 -0
- package/dist/types/client/IOCore.d.ts +408 -0
- package/dist/types/client/browser/IOWebSocket.d.ts +75 -0
- package/dist/types/common/constants.d.ts +169 -0
- package/dist/types/common/payload.d.ts +6 -0
- package/dist/types/common/quotaTable.d.ts +47 -0
- package/docs/README.ko.md +371 -0
- package/docs/iosignal_architecture.png +0 -0
- package/examples/react-chat-js/dist/assets/index-Cy4qaVcJ.js +56 -0
- package/examples/react-chat-js/dist/assets/index-NETrjYhz.css +1 -0
- package/examples/react-chat-js/dist/index.html +14 -0
- package/examples/react-chat-js/index.html +13 -0
- package/examples/react-chat-js/package-lock.json +1628 -0
- package/examples/react-chat-js/package.json +20 -0
- package/examples/react-chat-js/src/App.css +61 -0
- package/examples/react-chat-js/src/App.jsx +125 -0
- package/examples/react-chat-js/src/index.css +13 -0
- package/examples/react-chat-js/src/main.jsx +13 -0
- package/examples/react-chat-js/src/shared_io.js +12 -0
- package/examples/react-chat-js/vite.config.js +7 -0
- package/examples/server/index.js +12 -0
- package/examples/server/package.json +12 -0
- package/package.json +24 -12
- package/rollup.config.js +13 -8
- package/src/auth/Auth_File.js +1 -1
- package/src/client/IOCongSocket.js +20 -9
- package/src/client/IOCore.js +422 -77
- package/src/client/IOWS.js +12 -15
- package/src/client/browser/IOWebSocket.js +217 -0
- package/src/common/constants.js +91 -1
- package/test-nodejs/server-Auth_File.js +1 -1
- package/tsconfig.json +24 -0
- package/dist/iosignal.cjs +0 -23
- package/dist/iosignal.mjs +0 -23
- package/img/iosignal_stack.png +0 -0
- package/src/client/IOWebSocket.js +0 -118
- package/test-nodejs/client.cjs +0 -17
- package/test-nodejs/server-commonjs.cjs +0 -9
- /package/{auth_file.mjs → auth_file.js} +0 -0
- /package/test-nodejs/{client.mjs → client.js} +0 -0
- /package/test-nodejs/{client_api_reply.mjs → client_api_reply.js} +0 -0
- /package/test-nodejs/{server-esm.mjs → server.js} +0 -0
- /package/test-nodejs/{simple-server.mjs → simple-server.js} +0 -0
|
@@ -1,118 +0,0 @@
|
|
|
1
|
-
import {version} from "../../package.json";
|
|
2
|
-
import { IOCore } from "./IOCore.js";
|
|
3
|
-
import Boho from 'boho'
|
|
4
|
-
import * as constants from '../common/constants.js'
|
|
5
|
-
|
|
6
|
-
const Buffer = Boho.Buffer
|
|
7
|
-
|
|
8
|
-
// Browser WebSocket
|
|
9
|
-
export default class IO extends IOCore {
|
|
10
|
-
static version = version
|
|
11
|
-
static binaryType = "arraybuffer"
|
|
12
|
-
static Boho = Boho;
|
|
13
|
-
static MBP = Boho.MBP;
|
|
14
|
-
static Buffer = Boho.Buffer;
|
|
15
|
-
static constants = constants
|
|
16
|
-
|
|
17
|
-
constructor(url) {
|
|
18
|
-
super(url);
|
|
19
|
-
document.addEventListener('visibilitychange', this.browserVisiblePing.bind(this));
|
|
20
|
-
if (url) this.open();
|
|
21
|
-
}
|
|
22
|
-
|
|
23
|
-
browserVisiblePing() {
|
|
24
|
-
if (document.visibilityState === 'visible') {
|
|
25
|
-
this.ping()
|
|
26
|
-
}
|
|
27
|
-
}
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
close() {
|
|
31
|
-
if (this.socket) {
|
|
32
|
-
this.socket.onclose = null
|
|
33
|
-
this.socket.onmessage = null
|
|
34
|
-
this.socket.onerror = null
|
|
35
|
-
this.socket.close();
|
|
36
|
-
this.socket = null;
|
|
37
|
-
}
|
|
38
|
-
this.emit('close')
|
|
39
|
-
}
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
stop() {
|
|
43
|
-
this.close()
|
|
44
|
-
clearInterval(this.connectionCheckerIntervalID);
|
|
45
|
-
this.connectionCheckerIntervalID = null
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
keepAlive() {
|
|
50
|
-
if (!this.socket || this.socket?.readyState === 3) {
|
|
51
|
-
this.open();
|
|
52
|
-
}
|
|
53
|
-
}
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
createConnection(url) {
|
|
58
|
-
// Web Browser WebSocket
|
|
59
|
-
this.socket = new WebSocket(url);
|
|
60
|
-
this.socket.binaryType = IO.binaryType
|
|
61
|
-
|
|
62
|
-
this.stateChange('opening')
|
|
63
|
-
|
|
64
|
-
this.socket.onopen = () => {
|
|
65
|
-
if (this.socket.binaryType == "arraybuffer") {
|
|
66
|
-
this.socket.onmessage = this.onWebSocketMessage.bind(this);
|
|
67
|
-
} else { // blob
|
|
68
|
-
this.socket.onmessage = this.onWebSocketMessageBlob.bind(this);
|
|
69
|
-
}
|
|
70
|
-
this.emit('open');
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
this.socket.onerror = (e) => {
|
|
74
|
-
this.emit('error', e)
|
|
75
|
-
}
|
|
76
|
-
|
|
77
|
-
this.socket.onclose = () => {
|
|
78
|
-
this.emit('close');
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
onWebSocketMessage(event) {
|
|
83
|
-
// event.data is arrayBuffer or text_message
|
|
84
|
-
this.rxCounter++;
|
|
85
|
-
this.lastTxRxTime = Date.now();
|
|
86
|
-
let buffer = Buffer.from(event.data)
|
|
87
|
-
this.rxBytes += buffer.byteLength
|
|
88
|
-
this.emit('socket_data', buffer);
|
|
89
|
-
}
|
|
90
|
-
|
|
91
|
-
async onWebSocketMessageBlob(event) {
|
|
92
|
-
// event.data is Blob or text_message
|
|
93
|
-
this.rxCounter++;
|
|
94
|
-
this.lastTxRxTime = Date.now();
|
|
95
|
-
let buffer;
|
|
96
|
-
if (event.data instanceof Blob) {
|
|
97
|
-
let ab = await event.data.arrayBuffer()
|
|
98
|
-
buffer = Buffer.from(ab)
|
|
99
|
-
} else {
|
|
100
|
-
buffer = Buffer.from(event.data)
|
|
101
|
-
}
|
|
102
|
-
this.rxBytes += buffer.byteLength
|
|
103
|
-
this.emit('socket_data', buffer);
|
|
104
|
-
}
|
|
105
|
-
|
|
106
|
-
socket_send(data) {
|
|
107
|
-
if (this.socket?.readyState === 1) {
|
|
108
|
-
this.socket.send(data)
|
|
109
|
-
this.txCounter++;
|
|
110
|
-
this.txBytes += data.byteLength
|
|
111
|
-
this.lastTxRxTime = Date.now();
|
|
112
|
-
} else {
|
|
113
|
-
console.log('.')
|
|
114
|
-
}
|
|
115
|
-
}
|
|
116
|
-
|
|
117
|
-
}
|
|
118
|
-
|
package/test-nodejs/client.cjs
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
|
|
2
|
-
const { IO } = require('iosignal')
|
|
3
|
-
|
|
4
|
-
const io = new IO('ws://localhost:7777')
|
|
5
|
-
|
|
6
|
-
io.on('ready', () => {
|
|
7
|
-
console.log('ready cid:', io.cid)
|
|
8
|
-
io.signal('#screen', 'playToggle')
|
|
9
|
-
});
|
|
10
|
-
|
|
11
|
-
io.listen('#notify', (...args) => {
|
|
12
|
-
console.log(args)
|
|
13
|
-
})
|
|
14
|
-
|
|
15
|
-
io.on('error', err => {
|
|
16
|
-
console.log('err', err)
|
|
17
|
-
})
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|