feat(remote): 完善文件传输功能及WebSocket支持
This commit is contained in:
30
remote/test-simple.js
Normal file
30
remote/test-simple.js
Normal file
@@ -0,0 +1,30 @@
|
||||
const WebSocket = require('ws');
|
||||
|
||||
console.log('Starting...');
|
||||
const ws = new WebSocket('ws://146.56.248.142:8083/ws?password=wzw20040525');
|
||||
|
||||
ws.on('open', () => {
|
||||
console.log('Connected!');
|
||||
|
||||
let fileId = 'test_' + Date.now();
|
||||
const testContent = Buffer.from('Hello');
|
||||
|
||||
console.log('Sending fileUploadStart...');
|
||||
ws.send(JSON.stringify({
|
||||
type: 'fileUploadStart',
|
||||
fileId: fileId,
|
||||
filename: 'F:/test.txt',
|
||||
totalChunks: 1,
|
||||
fileSize: 5,
|
||||
requestId: 'req1'
|
||||
}));
|
||||
});
|
||||
|
||||
ws.on('message', (data, isBinary) => {
|
||||
console.log('Got message:', isBinary ? 'binary' : data.toString().substring(0,80));
|
||||
});
|
||||
|
||||
ws.on('error', e => console.log('Error:', e.message));
|
||||
ws.on('close', () => console.log('Closed'));
|
||||
|
||||
setTimeout(() => { console.log('Timeout'); process.exit(1); }, 10000);
|
||||
Reference in New Issue
Block a user