https://poiemaweb.com/nodejs-socketio
node와 npm 명령어를 어떤 경로에서든 사용할 수 있게 경로를 심볼릭 링크를 이용해서 설정해주자 위와 같이 ln -s /usr/local/lib/node-v8.11.3-linux-x64/bin/* /usr/local/bin/ node -v
var socket = require('socket.io-client')('http://localhost'); socket.on('connect', function(){}); socket.on('event', function(data){}); socket.on('disconnect', function(){}); Emits an event to the socket identified by the string name. Any other parameters can be included. All serializable datastr…
io.sockets.on('connection', function (socket) { var socketId = socket.id; var clientIp = socket.request.connection.remoteAddress; console.log(clientIp); }); web ip 확인 var getIP = require('ipware')().get_ip; var ipInfo = getIP(req); console.log("user web: "+ JSON.stringify(ipInfo));…
2. Server-Side Node.js 코드 예제 - Server-Side Javascript인 Node.js도 위 동작 방식과 동일하다. for (var i = 0; i < 10; i++){ // setTimeout 타이머와 같이 비동기로 동작한다 process.nextTick(function(){ console.log(i); // 10 }); } for (var i = 0; i < 10; i++){ // 타이머 이벤트에 즉시 실행 함수를 랩핑. (function(i){ process.nextT…
서버 var io = require('socket.io').listen(8001); io.sockets.on('connection', function (socket){ var room_id; socket.on('joinRoom',function(data){ room_id = data; socket.join(room_id); //룸입장 console.log('JOIN ROOM LIST', io.sockets.adapter.rooms); }); socket.on('leaveRoom',function(){ socket.leave(room…
# key 변경 openssl rsa -in server.key -text > private.pem # crt 변경 openssl x509 -inform PEM -in server.crt > public.pem const https = require('https'); const fs = require('fs'); const options = { ca: fs.readFileSync('인증서경로/ca-bundle.pem') key: fs.readFileSync('인증서경로/domain_xxxxx.key.pem'…
app.get('/', function(req, res) { db.open(function(err, db) { db.authenticate(USERID, PASS, function() { db.collection("", function(err, collection) { collection.find({},{}, function(err, cur) { res.render('index.jade', {}); …
** root 에서 작업진행 1.리눅스 버전확인 # cat /etc/*-release | uniq CentOS Linux release 7.3.1611 (Core) 2. repl 저장소 설치 # yum install epel-release 3. node.js npm 설치 # yum install npm nodejs 4. 최신버전 업데이트 (버전관리자 사용) # yum update openssl # npm cache clean -f # npm install -g n ** 특정버전 설치시 # n 6.11.0 ** 최신 안정화 …
[Ubuntu] inode full 해결을 위한 오래된 Kernel DATA 삭제 df -i 로 용량확인 cd /usr/src 에 파일 삭제 파일 확인법 http://hyunsoft.tistory.com/6 for i in *; do echo -e "$(find $i | wc -l)\t$i"; done | sort -n 그냥 파일 개수가 많아서 발생한거다. 필요없는 로그파일이나 세션, 캐쉬 파일등 을 삭제 해라. 무조건 많이 삭제 해서 사용량을 50%정도로 줄이면 성공