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.
Files changed (49) hide show
  1. package/README.md +248 -114
  2. package/dist/io.d.ts +481 -0
  3. package/dist/io.js +4 -5
  4. package/dist/io.js.map +1 -1
  5. package/dist/io.min.js +4 -5
  6. package/dist/io.min.js.map +1 -1
  7. package/dist/iosignal.js +9559 -0
  8. package/dist/types/client/IOCore.d.ts +408 -0
  9. package/dist/types/client/browser/IOWebSocket.d.ts +75 -0
  10. package/dist/types/common/constants.d.ts +169 -0
  11. package/dist/types/common/payload.d.ts +6 -0
  12. package/dist/types/common/quotaTable.d.ts +47 -0
  13. package/docs/README.ko.md +371 -0
  14. package/docs/iosignal_architecture.png +0 -0
  15. package/examples/react-chat-js/dist/assets/index-Cy4qaVcJ.js +56 -0
  16. package/examples/react-chat-js/dist/assets/index-NETrjYhz.css +1 -0
  17. package/examples/react-chat-js/dist/index.html +14 -0
  18. package/examples/react-chat-js/index.html +13 -0
  19. package/examples/react-chat-js/package-lock.json +1628 -0
  20. package/examples/react-chat-js/package.json +20 -0
  21. package/examples/react-chat-js/src/App.css +61 -0
  22. package/examples/react-chat-js/src/App.jsx +125 -0
  23. package/examples/react-chat-js/src/index.css +13 -0
  24. package/examples/react-chat-js/src/main.jsx +13 -0
  25. package/examples/react-chat-js/src/shared_io.js +12 -0
  26. package/examples/react-chat-js/vite.config.js +7 -0
  27. package/examples/server/index.js +12 -0
  28. package/examples/server/package.json +12 -0
  29. package/package.json +24 -12
  30. package/rollup.config.js +13 -8
  31. package/src/auth/Auth_File.js +1 -1
  32. package/src/client/IOCongSocket.js +20 -9
  33. package/src/client/IOCore.js +422 -77
  34. package/src/client/IOWS.js +12 -15
  35. package/src/client/browser/IOWebSocket.js +217 -0
  36. package/src/common/constants.js +91 -1
  37. package/test-nodejs/server-Auth_File.js +1 -1
  38. package/tsconfig.json +24 -0
  39. package/dist/iosignal.cjs +0 -23
  40. package/dist/iosignal.mjs +0 -23
  41. package/img/iosignal_stack.png +0 -0
  42. package/src/client/IOWebSocket.js +0 -118
  43. package/test-nodejs/client.cjs +0 -17
  44. package/test-nodejs/server-commonjs.cjs +0 -9
  45. /package/{auth_file.mjs → auth_file.js} +0 -0
  46. /package/test-nodejs/{client.mjs → client.js} +0 -0
  47. /package/test-nodejs/{client_api_reply.mjs → client_api_reply.js} +0 -0
  48. /package/test-nodejs/{server-esm.mjs → server.js} +0 -0
  49. /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
-
@@ -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
- })
@@ -1,9 +0,0 @@
1
- let { Server } = require('iosignal')
2
-
3
- const server = new Server(
4
- {
5
- port: 7777, // WebSocket
6
- congPort: 8888, // CongSocket
7
- showMetric: 2, // show clients cid(state) info
8
- showMessage: 'message' // show raw signal buffer
9
- })
File without changes
File without changes
File without changes