feat: 초기 프로젝트 설정 및 룰.md 파일 추가
This commit is contained in:
29
api.hyungi.net/node_modules/nssocket/examples/reconnect.js
generated
vendored
Normal file
29
api.hyungi.net/node_modules/nssocket/examples/reconnect.js
generated
vendored
Normal file
@@ -0,0 +1,29 @@
|
||||
var net = require('net'),
|
||||
nssocket = require('../lib/nssocket');
|
||||
|
||||
net.createServer(function (socket) {
|
||||
//
|
||||
// Close the underlying socket after `1000ms`
|
||||
//
|
||||
setTimeout(function () {
|
||||
socket.destroy();
|
||||
}, 1000);
|
||||
}).listen(8345);
|
||||
|
||||
//
|
||||
// Create an NsSocket instance with reconnect enabled
|
||||
//
|
||||
var socket = new nssocket.NsSocket({
|
||||
reconnect: true,
|
||||
type: 'tcp4',
|
||||
});
|
||||
|
||||
socket.on('start', function () {
|
||||
//
|
||||
// The socket will emit this event periodically
|
||||
// as it attempts to reconnect
|
||||
//
|
||||
console.dir('start');
|
||||
});
|
||||
|
||||
socket.connect(8345);
|
||||
Reference in New Issue
Block a user