μ λ°μνκ³ μ΄λ»κ² κ³ μΉ μ μμ΅λκΉ? λμμ£ΌμΈμ~
μ΄λμμ μ€λ₯:
...\socket.io-adapter\index.js:195
if (fn) process.nextTick(fn.bind(null, null, sids));
socket.io λ²μ :
1.4.5
"Node.js in action" μ± μμ λ©ν°λ£Έ μ±ν μ ν리μΌμ΄μ μ λΉλνλ λμ λμΌν μ€λ₯κ° λ°μνμ΅λλ€.
<MY_PATH>\chatrooms\node_modules\socket.io-adapter\index.js:195
if (fn) process.nextTick(fn.bind(null, null, sids));
^
TypeError: fn.bind is not a function
at Adapter.clients (<MY_PATH>\chatrooms\node_modules\socket.io-adapter\index.js:195:31)
at Namespace.clients (<MY_PATH>\chatrooms\node_modules\socket.io\lib\namespace.js:253:16)
at joinRoom (<MY_PATH>\chatrooms\lib\chat_server.js:71:32)
at Namespace.<anonymous> (<MY_PATH>\chatrooms\lib\chat_server.js:20:5)
at emitOne (events.js:90:13)
at Namespace.emit (events.js:182:7)
at Namespace.emit (<MY_PATH>\chatrooms\node_modules\socket.io\lib\namespace.js:206:10)
at <MY_PATH>\chatrooms\node_modules\socket.io\lib\namespace.js:174:14
at _combinedTickCallback (node.js:370:9)
at process._tickCallback (node.js:401:11)
μ’ μμ±μ μ΅μ λ²μ μΌλ‘ μ λ°μ΄νΈνλ©΄ λ¬Έμ κ° λνλ©λλ€.
"dependencies": {
"mime": "^1.3.4",
"socket.io": "^1.4.5"
}
μ± μμ μ§μ ν μ’ μμ±μ μ¬μ©νλ κ²½μ° μλνλ λμ
"dependencies": {
"socket.io": "~0.9.6",
"mime": "~1.2.7"
}
BTW, μ¬κΈ°μ λκΈμ λ¬κΈ° μ μ socket.io μ¬μ΄νΈμμ Migration from 0.9 νμ΄μ§λ₯Ό μ½μμ§λ§ ν΄κ²°μ± μ μ°Ύμ§ λͺ»νμ΅λλ€.
νμν κ²½μ° κ°λ¨ν μ±ν νλ‘μ νΈλ₯Ό μ΄λκ°μ μ λ‘λν μ μμ΅λλ€(λ§€μ° μμ).
λλ NodeJs in action μ± μμ μμ λ₯Ό νμΈνμΌλ©°, μ΅μ λ²μ μ socket.ioλ₯Ό μ¬μ©νλ©΄ λ¬Όλ‘ μλνμ§ μμ κ²μ λλ€. μλνλ €λ©΄ λ€μ 2μ€μ΄ μμ΄μΌ ν©λλ€.
μμ:
var usersInRoom = io.sockets.clients(room);
μκ²:
var usersInRoom = io.of('/').in(room).clients;
κ·Έλ¦¬κ³ μΆλ°:
socket.emit('rooms', io.sockets.manager.rooms);
μκ²:
socket.emit('rooms', io.of('/').adapter.rooms);
μΈμ¬λ§!
thnx @CheckMater
thnx @CheckMater
thnx @CheckMater
thnx @CheckMater
thnx @CheckMater
κ°μ¬ ν©λλ€. @CheckMater
@CheckMater κ°μ¬ν©λλ€
@CheckMater κ°μ¬ν©λλ€
@CheckMater κ°μ¬ν©λλ€
@CheckMater κ°μ¬ν©λλ€
@CheckMater κ°μ¬ν©λλ€. κ·Έλ¬λ λ¨μν var usersInRoom = io.of('/').in(room).clients;
λ₯Ό λ³κ²½νλ κ²μ ν¨κ³Όκ° μμμ΅λλ€. μ΄ ν΄λΌμ΄μΈνΈλ μ½λ°±μ 맀κ°λ³μλ‘ μ¬μ©νλ ν¨μμ΄λ―λ‘ μλ μ€λν«μ΄ μ μκ² ν¨κ³Όμ μ΄μμ΅λλ€.
io.of('/').in(room).clients(function(error,clients){
var otherUsers = [];
for(var i in clients){
if(socket.id != clients[i]) otherUsers.push(nickNames[clients[i]]);
}
var userSummary = 'Users Currently in ' + room + ' are : ' + otherUsers.join(', ') + '.';
socket.emit('message',{text:userSummary});
});
console.log(io.of('/').in(room).clients);
ReferenceError: λ°©μ΄ μ μλμ§ μμμ΅λλ€ : findClientsSocketμμ
thnx @CheckMater
thnx @CheckMater
thx @CheckMater
@CheckMater κ°μ¬ν©λλ€
κ°μ₯ μ μ©ν λκΈ
λλ NodeJs in action μ± μμ μμ λ₯Ό νμΈνμΌλ©°, μ΅μ λ²μ μ socket.ioλ₯Ό μ¬μ©νλ©΄ λ¬Όλ‘ μλνμ§ μμ κ²μ λλ€. μλνλ €λ©΄ λ€μ 2μ€μ΄ μμ΄μΌ ν©λλ€.
μμ:
var usersInRoom = io.sockets.clients(room);
μκ²:
var usersInRoom = io.of('/').in(room).clients;
κ·Έλ¦¬κ³ μΆλ°:
socket.emit('rooms', io.sockets.manager.rooms);
μκ²:
socket.emit('rooms', io.of('/').adapter.rooms);
μΈμ¬λ§!