iosignal 3.2.0 → 4.0.0

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 (76) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/README.en.md +56 -0
  3. package/README.md +39 -782
  4. package/dist/io.d.ts +10 -3
  5. package/dist/io.js +4 -4
  6. package/dist/io.js.map +1 -1
  7. package/dist/io.min.js +4 -4
  8. package/dist/io.min.js.map +1 -1
  9. package/dist/iosignal.js +266 -217
  10. package/dist/types/client/IOCore.d.ts +10 -3
  11. package/package.json +3 -4
  12. package/src/api/RedisAPI.js +19 -31
  13. package/src/api/api_reply.js +14 -6
  14. package/src/api/api_sudo.js +2 -8
  15. package/src/auth/Auth_Redis.js +8 -3
  16. package/src/auth/BohoAuth.js +12 -12
  17. package/src/client/CongPacket.js +2 -0
  18. package/src/client/IOCore.js +98 -52
  19. package/src/server/Manager.js +12 -12
  20. package/src/server/Metric.js +1 -2
  21. package/src/server/RemoteCore.js +27 -34
  22. package/src/server/Server.js +69 -60
  23. package/src/server/serverOption.js +3 -2
  24. package/README.ko.md +0 -566
  25. package/docs/iosignal_architecture.png +0 -0
  26. package/examples/react-chat-js/dist/assets/index-Cy4qaVcJ.js +0 -56
  27. package/examples/react-chat-js/dist/assets/index-NETrjYhz.css +0 -1
  28. package/examples/react-chat-js/dist/index.html +0 -14
  29. package/examples/react-chat-js/index.html +0 -13
  30. package/examples/react-chat-js/package-lock.json +0 -1723
  31. package/examples/react-chat-js/package.json +0 -20
  32. package/examples/react-chat-js/src/App.css +0 -61
  33. package/examples/react-chat-js/src/App.jsx +0 -125
  34. package/examples/react-chat-js/src/index.css +0 -13
  35. package/examples/react-chat-js/src/main.jsx +0 -13
  36. package/examples/react-chat-js/src/shared_io.js +0 -12
  37. package/examples/react-chat-js/vite.config.js +0 -7
  38. package/examples/server/index.js +0 -12
  39. package/examples/server/package-lock.json +0 -47
  40. package/examples/server/package.json +0 -12
  41. package/examples/svelte-chat-js/.devtools +0 -3
  42. package/examples/svelte-chat-js/README.md +0 -38
  43. package/examples/svelte-chat-js/package-lock.json +0 -1505
  44. package/examples/svelte-chat-js/package.json +0 -22
  45. package/examples/svelte-chat-js/src/app.css +0 -105
  46. package/examples/svelte-chat-js/src/app.d.ts +0 -13
  47. package/examples/svelte-chat-js/src/app.html +0 -12
  48. package/examples/svelte-chat-js/src/lib/images/github.svg +0 -1
  49. package/examples/svelte-chat-js/src/lib/images/svelte-logo.svg +0 -1
  50. package/examples/svelte-chat-js/src/lib/images/svelte-welcome.png +0 -0
  51. package/examples/svelte-chat-js/src/lib/images/svelte-welcome.webp +0 -0
  52. package/examples/svelte-chat-js/src/lib/shared_io.js +0 -12
  53. package/examples/svelte-chat-js/src/routes/+layout.svelte +0 -9
  54. package/examples/svelte-chat-js/src/routes/+page.js +0 -3
  55. package/examples/svelte-chat-js/src/routes/+page.svelte +0 -162
  56. package/examples/svelte-chat-js/static/favicon.svg +0 -1
  57. package/examples/svelte-chat-js/static/global.css +0 -19
  58. package/examples/svelte-chat-js/static/robots.txt +0 -3
  59. package/examples/svelte-chat-js/svelte.config.js +0 -15
  60. package/examples/svelte-chat-js/vite.config.js +0 -6
  61. package/test-browser/favicon.ico +0 -0
  62. package/test-browser/index.html +0 -95
  63. package/test-browser/server.js +0 -12
  64. package/test-nodejs/client-playToggle.js +0 -19
  65. package/test-nodejs/client.js +0 -17
  66. package/test-nodejs/client_api_reply.js +0 -15
  67. package/test-nodejs/server-Auth_Env.js +0 -19
  68. package/test-nodejs/server-Auth_File.js +0 -12
  69. package/test-nodejs/server-api_reply.js +0 -6
  70. package/test-nodejs/server-api_sudo.js +0 -7
  71. package/test-nodejs/server.js +0 -20
  72. package/test-nodejs/signalPack.js +0 -34
  73. package/test-nodejs/signaling.js +0 -61
  74. package/test-nodejs/simple-server.js +0 -13
  75. /package/{auth_file.js → auth_file_sample.js} +0 -0
  76. /package/{auth_file.json → auth_file_sample.json} +0 -0
@@ -1,20 +0,0 @@
1
- {
2
- "name": "react-chat-js",
3
- "private": true,
4
- "version": "1.0.0",
5
- "type": "module",
6
- "scripts": {
7
- "dev": "vite",
8
- "build": "vite build",
9
- "preview": "vite preview"
10
- },
11
- "dependencies": {
12
- "iosignal": "file:../..",
13
- "react": "^19.1.1",
14
- "react-dom": "^19.1.1"
15
- },
16
- "devDependencies": {
17
- "@vitejs/plugin-react": "^5.0.1",
18
- "vite": "^7.1.3"
19
- }
20
- }
@@ -1,61 +0,0 @@
1
- html, body, #root, .App {
2
- height: 100%;
3
- margin: 0;
4
- display: flex;
5
- flex-direction: column;
6
- }
7
-
8
- .App {
9
- padding: 20px;
10
- box-sizing: border-box;
11
- }
12
-
13
- h1 {
14
- margin-top: 0;
15
- color: #333;
16
- }
17
-
18
- .messages {
19
- flex-grow: 1; /* 남은 공간을 모두 차지하도록 설정 */
20
- border: 1px solid #ccc;
21
- padding: 10px;
22
- overflow-y: auto; /* 내용이 넘치면 스크롤바 표시 */
23
- margin-bottom: 10px;
24
- display: flex;
25
- flex-direction: column; /* 메시지를 아래에서 위로 쌓이도록 */
26
- justify-content: flex-end; /* 메시지를 아래로 정렬 */
27
- }
28
-
29
- .messages div {
30
- background-color: #f0f0f0;
31
- padding: 8px;
32
- margin-bottom: 5px;
33
- border-radius: 5px;
34
- text-align: left;
35
- }
36
-
37
- .input-area {
38
- display: flex;
39
- gap: 10px;
40
- margin-top: auto; /* 항상 하단에 위치하도록 */
41
- }
42
-
43
- .input-area input {
44
- flex-grow: 1;
45
- padding: 10px;
46
- border: 1px solid #ccc;
47
- border-radius: 5px;
48
- }
49
-
50
- .input-area button {
51
- padding: 10px 15px;
52
- background-color: #007bff;
53
- color: white;
54
- border: none;
55
- border-radius: 5px;
56
- cursor: pointer;
57
- }
58
-
59
- .input-area button:hover {
60
- background-color: #0056b3;
61
- }
@@ -1,125 +0,0 @@
1
- import { useState, useEffect, useRef } from 'react';
2
- import './App.css';
3
- import IO from 'iosignal/io.js';
4
-
5
- const url = 'ws://localhost:7777';
6
- const channel_tag = 'channel#topic';
7
-
8
- function App() {
9
- const [messages, setMessages] = useState([]);
10
- const [input, setInput] = useState('Hello, World!');
11
- const [ioState, setIoState] = useState(null); // ioState is updated by io.on('change')
12
- const [cid, setCid] = useState(null); // cid is updated by io.on('ready')
13
- const [counts, setCounts] = useState({ instances: 0, websockets: 0 }); // State for IO counts
14
- const ioRef = useRef(null); // Manage io instance with useRef
15
- const messagesEndRef = useRef(null);
16
-
17
- const scrollToBottom = () => {
18
- messagesEndRef.current?.scrollIntoView({ behavior: "smooth" });
19
- };
20
-
21
- useEffect(() => {
22
- scrollToBottom();
23
- }, [messages]);
24
-
25
- useEffect(() => {
26
- console.log(IO.version)
27
- ioRef.current = new IO(url); // Create io instance with URL
28
- setCounts({ instances: IO.instanceCount, websockets: IO.webSocketCount }); // Set initial counts
29
-
30
- if (!ioRef.current) {
31
- console.error('IO instance is not initialized.');
32
- return;
33
- }
34
-
35
- const handleReady = () => {
36
- console.log('ready cid:', ioRef.current.cid);
37
- setCid(ioRef.current.cid); // Update cid state
38
- ioRef.current.subscribe(channel_tag); // Subscribe to channel
39
- };
40
-
41
- const handleChange = (state) => {
42
- setIoState(state);
43
- setCounts({ instances: IO.instanceCount, websockets: IO.webSocketCount }); // Update counts on state change
44
- };
45
-
46
- const handleChannelMessage = (msgObj, tag) => {
47
- console.log('Received message in App:', msgObj, tag);
48
- if( typeof msgObj === 'string' ) {
49
- msgObj = { text: msgObj, cid: 'cli unknown' }; // Convert string to object if necessary
50
- }
51
- setMessages((prevMessages) => [...prevMessages, `${msgObj.cid} : ${msgObj.text}`]); // Update messages state]);
52
- };
53
-
54
- const handleError = (error) => {
55
- console.error('IO Error in App:', error);
56
- setIoState(`Error: ${error.message}`);
57
- };
58
-
59
- ioRef.current.on('ready', handleReady);
60
- ioRef.current.on('change', handleChange);
61
- ioRef.current.on(channel_tag, handleChannelMessage); // Add channel message listener
62
- ioRef.current.on('error', handleError);
63
-
64
-
65
- // Cleanup function: remove event listeners when component unmounts
66
- return () => {
67
- ioRef.current.off('ready', handleReady);
68
- ioRef.current.off('change', handleChange);
69
- ioRef.current.off(channel_tag, handleChannelMessage);
70
- ioRef.current.off('error', handleError);
71
-
72
- // destroy() is called to clean up the io instance, all listeners are removed automatically
73
- ioRef.current.destroy(); // Clean up the io instance
74
- console.log('IO instance destroyed.');
75
- ioRef.current = null; // Release the io instance reference
76
- };
77
- }, []); // Empty dependency array ensures this runs only once on mount
78
-
79
- const sendMessage = () => {
80
- if (input.trim()) {
81
- console.log('Sending message:', input);
82
- const msgObj = { text: input, cid: ioRef.current.cid };
83
- console.log('Sending message object:', msgObj);
84
- ioRef.current.signal(channel_tag, msgObj); // Send message to channel
85
- setInput('date' + Date.now());
86
- }
87
- };
88
-
89
- const ioStateStyle = {
90
- color: ioState === 'ready' ? 'green' : 'red',
91
- fontWeight: 'bold',
92
- };
93
-
94
- return (
95
- <div className="App">
96
- <h1>React Chat Example</h1>
97
- <div>URL: {url}</div>
98
- <div>Channel: {channel_tag}</div>
99
- <div>IO State: <span style={ioStateStyle}>{ioState}</span></div>
100
- <div>Client ID: {cid}</div>
101
- <div>IO Instances: {counts.instances}</div>
102
- <div>WebSockets Created: {counts.websockets}</div>
103
- <div className="messages">
104
- {messages.map((msg, index) => (
105
- <div key={index}>{msg}</div>
106
- ))}
107
- <div ref={messagesEndRef} />
108
- </div>
109
- <div className="input-area">
110
- <input
111
- type="text"
112
- value={input}
113
- onChange={(e) => setInput(e.target.value)}
114
- onKeyUp={(e) => e.key === 'Enter' && sendMessage()}
115
- disabled={ioState !== 'ready'}
116
- />
117
- <button onClick={sendMessage} disabled={ioState !== 'ready'}>
118
- Send
119
- </button>
120
- </div>
121
- </div>
122
- );
123
- }
124
-
125
- export default App;
@@ -1,13 +0,0 @@
1
- body {
2
- margin: 0;
3
- font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', 'Roboto', 'Oxygen',
4
- 'Ubuntu', 'Cantarell', 'Fira Sans', 'Droid Sans', 'Helvetica Neue',
5
- sans-serif;
6
- -webkit-font-smoothing: antialiased;
7
- -moz-osx-font-smoothing: grayscale;
8
- }
9
-
10
- code {
11
- font-family: source-code-pro, Menlo, Monaco, Consolas, 'Courier New',
12
- monospace;
13
- }
@@ -1,13 +0,0 @@
1
- import React from 'react'
2
- import ReactDOM from 'react-dom/client'
3
- import App from './App.jsx'
4
- import './index.css'
5
-
6
- const strictModeEnabled = true; // true/false 바꾸기만 하면 됨
7
-
8
-
9
- ReactDOM.createRoot(document.getElementById('root')).render(
10
- strictModeEnabled
11
- ? <React.StrictMode><App /></React.StrictMode>
12
- : <App />
13
- )
@@ -1,12 +0,0 @@
1
- import IO from 'iosignal/io.js'
2
-
3
-
4
- const url = 'ws://localhost:7777';
5
- const io = new IO(url);
6
- const channel = 'chat';
7
-
8
-
9
- console.log('IO instance created:', io);
10
-
11
- export { io, channel};
12
-
@@ -1,7 +0,0 @@
1
- import { defineConfig } from 'vite'
2
- import react from '@vitejs/plugin-react'
3
-
4
- // https://vitejs.dev/config/
5
- export default defineConfig({
6
- plugins: [react()],
7
- })
@@ -1,12 +0,0 @@
1
- import { Server } from "iosignal"
2
-
3
- const server = new Server(
4
- {
5
- port: 7777,
6
- congPort: 8888,
7
- showMetric: 2,
8
- showMessage: 'message' // show signal message
9
- })
10
-
11
-
12
- console.log('Signaling server started. Listening on port 7777 and congPort 8888');
@@ -1,47 +0,0 @@
1
- {
2
- "name": "iosignal-example-server",
3
- "version": "1.0.0",
4
- "lockfileVersion": 3,
5
- "requires": true,
6
- "packages": {
7
- "": {
8
- "name": "iosignal-example-server",
9
- "version": "1.0.0",
10
- "dependencies": {
11
- "iosignal": "file:../.."
12
- }
13
- },
14
- "../..": {
15
- "version": "3.2.0",
16
- "license": "MIT",
17
- "dependencies": {
18
- "boho": "^1.1.1",
19
- "eventemitter3": "^5.0.1",
20
- "meta-buffer-pack": "^2.1.0",
21
- "ws": "^8.18.3"
22
- },
23
- "devDependencies": {
24
- "@rollup/plugin-commonjs": "^28.0.0",
25
- "@rollup/plugin-json": "^6.1.0",
26
- "@rollup/plugin-node-resolve": "^15.3.0",
27
- "@rollup/plugin-replace": "^6.0.1",
28
- "@rollup/plugin-terser": "^0.4.4",
29
- "@types/node": "^24.1.0",
30
- "rollup": "^4.36.0",
31
- "rollup-plugin-dts": "^6.2.1",
32
- "typescript": "^5.8.3"
33
- },
34
- "engines": {
35
- "node": ">=18.0.0"
36
- },
37
- "optionalDependencies": {
38
- "bufferutil": "^4.0.9",
39
- "utf-8-validate": "^6.0.5"
40
- }
41
- },
42
- "node_modules/iosignal": {
43
- "resolved": "../..",
44
- "link": true
45
- }
46
- }
47
- }
@@ -1,12 +0,0 @@
1
- {
2
- "name": "iosignal-example-server",
3
- "version": "1.0.0",
4
- "main": "index.js",
5
- "type": "module",
6
- "scripts": {
7
- "start": "node index.js"
8
- },
9
- "dependencies": {
10
- "iosignal": "file:../.."
11
- }
12
- }
@@ -1,3 +0,0 @@
1
- {
2
- "sources": ["/src"]
3
- }
@@ -1,38 +0,0 @@
1
- # sv
2
-
3
- Everything you need to build a Svelte project, powered by [`sv`](https://github.com/sveltejs/cli).
4
-
5
- ## Creating a project
6
-
7
- If you're seeing this, you've probably already done this step. Congrats!
8
-
9
- ```sh
10
- # create a new project in the current directory
11
- npx sv create
12
-
13
- # create a new project in my-app
14
- npx sv create my-app
15
- ```
16
-
17
- ## Developing
18
-
19
- Once you've created a project and installed dependencies with `npm install` (or `pnpm install` or `yarn`), start a development server:
20
-
21
- ```sh
22
- npm run dev
23
-
24
- # or start the server and open the app in a new browser tab
25
- npm run dev -- --open
26
- ```
27
-
28
- ## Building
29
-
30
- To create a production version of your app:
31
-
32
- ```sh
33
- npm run build
34
- ```
35
-
36
- You can preview the production build with `npm run preview`.
37
-
38
- > To deploy your app, you may need to install an [adapter](https://svelte.dev/docs/kit/adapters) for your target environment.