mirror of
https://github.com/zhigang1992/DefinitelyTyped.git
synced 2026-04-01 09:01:45 +08:00
socket.io : fix for functions used in storing data associated with client. Closes #734
This commit is contained in:
@@ -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);
|
||||
});
|
||||
});
|
||||
});
|
||||
2
socket.io/socket.io.d.ts
vendored
2
socket.io/socket.io.d.ts
vendored
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user