Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

socket.io : fix for functions used in storing data associated with cl…

…ient. Closes #734
  • Loading branch information...
commit a12a8fdfda9020dbc1aec4170ce8afbb7688766c 1 parent 37b4cae
@basarat basarat authored
Showing with 15 additions and 1 deletion.
  1. +14 −0 socket.io/socket.io-tests.ts
  2. +1 −1  socket.io/socket.io.d.ts
View
14 socket.io/socket.io-tests.ts
@@ -7,4 +7,18 @@ socketManager.sockets.on('connection', socket => {
socket.on('my other event', data => {
console.log(data);
});
+});
+
+// Storing data Associated to a client.
+// Server side sample
+io.listen(80).sockets.on('connection', function (socket) {
+ socket.on('set nickname', function (name) {
+ socket.set('nickname', name, function () { socket.emit('ready'); });
+ });
+
+ socket.on('msg', function () {
+ socket.get('nickname', function (err, name) {
+ console.log('Chat message by ', name);
+ });
+ });
});
View
2  socket.io/socket.io.d.ts
@@ -24,7 +24,7 @@ interface Socket {
join(name: string, fn: Function): Socket;
unjoin(name: string, fn: Function): Socket;
set(key: string, value: any, fn: Function): Socket;
- get(key: string, value: any, fn: Function): Socket;
+ get(key: string, fn: Function): Socket;
has(key: string, fn: Function): Socket;
del(key: string, fn: Function): Socket;
disconnect(): Socket;
Please sign in to comment.
Something went wrong with that request. Please try again.