iosignal 3.3.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 (68) hide show
  1. package/.vscode/settings.json +3 -0
  2. package/README.en.md +56 -0
  3. package/README.md +40 -559
  4. package/dist/io.d.ts +5 -0
  5. package/dist/io.js +1 -1
  6. package/dist/io.js.map +1 -1
  7. package/dist/io.min.js +1 -1
  8. package/dist/io.min.js.map +1 -1
  9. package/dist/iosignal.js +80 -45
  10. package/dist/types/client/IOCore.d.ts +5 -0
  11. package/package.json +3 -4
  12. package/src/client/IOCore.js +71 -41
  13. package/src/server/Manager.js +9 -8
  14. package/README.ko.md +0 -566
  15. package/docs/iosignal_architecture.png +0 -0
  16. package/examples/react-chat-js/dist/assets/index-Cy4qaVcJ.js +0 -56
  17. package/examples/react-chat-js/dist/assets/index-NETrjYhz.css +0 -1
  18. package/examples/react-chat-js/dist/assets/index-e2KOTYW8.js +0 -65
  19. package/examples/react-chat-js/dist/index.html +0 -14
  20. package/examples/react-chat-js/index.html +0 -13
  21. package/examples/react-chat-js/package-lock.json +0 -1723
  22. package/examples/react-chat-js/package.json +0 -20
  23. package/examples/react-chat-js/src/App.css +0 -61
  24. package/examples/react-chat-js/src/App.jsx +0 -125
  25. package/examples/react-chat-js/src/index.css +0 -13
  26. package/examples/react-chat-js/src/main.jsx +0 -13
  27. package/examples/react-chat-js/src/shared_io.js +0 -12
  28. package/examples/react-chat-js/vite.config.js +0 -7
  29. package/examples/server/index.js +0 -65
  30. package/examples/server/package-lock.json +0 -878
  31. package/examples/server/package.json +0 -13
  32. package/examples/server/public/index.html +0 -26
  33. package/examples/svelte-chat-js/.devtools +0 -3
  34. package/examples/svelte-chat-js/README.md +0 -38
  35. package/examples/svelte-chat-js/package-lock.json +0 -1421
  36. package/examples/svelte-chat-js/package.json +0 -23
  37. package/examples/svelte-chat-js/src/app.css +0 -105
  38. package/examples/svelte-chat-js/src/app.d.ts +0 -13
  39. package/examples/svelte-chat-js/src/app.html +0 -13
  40. package/examples/svelte-chat-js/src/lib/images/github.svg +0 -1
  41. package/examples/svelte-chat-js/src/lib/images/svelte-logo.svg +0 -1
  42. package/examples/svelte-chat-js/src/lib/images/svelte-welcome.png +0 -0
  43. package/examples/svelte-chat-js/src/lib/images/svelte-welcome.webp +0 -0
  44. package/examples/svelte-chat-js/src/lib/shared_io.js +0 -12
  45. package/examples/svelte-chat-js/src/routes/+layout.svelte +0 -5
  46. package/examples/svelte-chat-js/src/routes/+page.js +0 -3
  47. package/examples/svelte-chat-js/src/routes/+page.svelte +0 -167
  48. package/examples/svelte-chat-js/static/favicon.svg +0 -1
  49. package/examples/svelte-chat-js/static/global.css +0 -19
  50. package/examples/svelte-chat-js/static/robots.txt +0 -3
  51. package/examples/svelte-chat-js/svelte.config.js +0 -23
  52. package/examples/svelte-chat-js/vite.config.js +0 -6
  53. package/test-browser/favicon.ico +0 -0
  54. package/test-browser/index.html +0 -95
  55. package/test-browser/server.js +0 -12
  56. package/test-nodejs/client-playToggle.js +0 -19
  57. package/test-nodejs/client.js +0 -17
  58. package/test-nodejs/client_api_reply.js +0 -15
  59. package/test-nodejs/server-Auth_Env.js +0 -19
  60. package/test-nodejs/server-Auth_File.js +0 -12
  61. package/test-nodejs/server-api_reply.js +0 -6
  62. package/test-nodejs/server-api_sudo.js +0 -7
  63. package/test-nodejs/server.js +0 -20
  64. package/test-nodejs/signalPack.js +0 -34
  65. package/test-nodejs/signaling.js +0 -61
  66. package/test-nodejs/simple-server.js +0 -13
  67. /package/{auth_file.js → auth_file_sample.js} +0 -0
  68. /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,65 +0,0 @@
1
-
2
- import { Server, api_reply } from 'iosignal'
3
- import express from 'express';
4
- import path from 'path';
5
- import { fileURLToPath } from 'url';
6
-
7
- // __dirname 대체 (ESM에서는 직접 사용 불가)
8
- const __filename = fileURLToPath(import.meta.url);
9
- const __dirname = path.dirname(__filename);
10
-
11
- const app = express();
12
- let PORT = 7777;
13
-
14
- // 정적 파일 제공
15
- app.use(express.static(path.join(__dirname, 'public')));
16
-
17
- app.use(
18
- '/dist',
19
- // 실시간 iosigal 코드 수정 테스트시.
20
- express.static(path.join(__dirname, '../../', 'dist'))
21
- // 설치된 패키지 사용시
22
- // express.static(path.join(__dirname, 'node_modules', 'iosignal', 'dist'))
23
- );
24
-
25
- app.use('/chat/svelte',
26
- express.static(path.join(__dirname, '../svelte-chat-js/build/'))
27
- );
28
- app.use('/chat/react',
29
- express.static(path.join(__dirname, '../react-chat-js/dist/'))
30
- );
31
- app.use('/assets',
32
- express.static(path.join(__dirname, '../react-chat-js/dist/assets'))
33
- );
34
-
35
- // 기본 라우트 (index.html 제공)
36
- app.get('/', (req, res) => {
37
- res.sendFile(path.join(__dirname, 'public', 'index.html'));
38
- });
39
-
40
- let httpServer = app.listen(PORT, () => {
41
- if(PORT == 0 ){
42
- PORT = httpServer.address().port
43
- }
44
- console.log(`🚀 서버 실행 중: http://localhost:${PORT}`);
45
- });
46
-
47
-
48
-
49
-
50
-
51
- // httpServer.listen(8080);
52
-
53
-
54
- const options = {
55
- httpServer: httpServer,
56
- // showMetric: 2,
57
- showMessage: 'message'
58
- }
59
- const ioss = new Server( options)
60
-
61
- // api response module
62
- ioss.api('reply', api_reply)
63
-
64
-
65
-