31 lines
806 B
JavaScript
31 lines
806 B
JavaScript
|
|
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);
|