mirror of
https://github.com/gosticks/DefinitelyTyped.git
synced 2026-12-04 12:11:47 +00:00
Merge pull request #26530 from lukaszluczak/master
[express-socket.io-session] Added "session" and "sessionID" to SocketIO.Socket.handshake
This commit is contained in:
@@ -26,3 +26,19 @@ io.use(sharedsession(session));
|
||||
io.use(sharedsession(session, { autoSave: true, saveUninitialized: true }));
|
||||
io.use(sharedsession(session, cookieParser));
|
||||
io.use(sharedsession(session, cookieParser, { autoSave: true, saveUninitialized: true }));
|
||||
|
||||
io.on('connection', (socket) => {
|
||||
const sessionID = [
|
||||
socket.handshake.sessionID,
|
||||
socket.handshake.session!.id
|
||||
];
|
||||
const sessionData = [
|
||||
socket.handshake.session!['sessionEntry'],
|
||||
socket.handshake.session!.anotherSessionEntry
|
||||
];
|
||||
socket.handshake.session!.touch(() => {});
|
||||
socket.handshake.session!.regenerate(() => {});
|
||||
socket.handshake.session!.save(() => {});
|
||||
socket.handshake.session!.reload(() => {});
|
||||
socket.handshake.session!.destroy(() => {});
|
||||
});
|
||||
|
||||
+7
@@ -7,6 +7,13 @@
|
||||
import socketio = require('socket.io');
|
||||
import express = require('express');
|
||||
|
||||
declare module "socket.io" {
|
||||
interface Handshake {
|
||||
session?: Express.Session;
|
||||
sessionID?: string;
|
||||
}
|
||||
}
|
||||
|
||||
declare function sharedsession(
|
||||
expressSessionMiddleware: express.RequestHandler,
|
||||
cookieParserMiddleware: express.RequestHandler,
|
||||
|
||||
Vendored
+45
-44
@@ -553,49 +553,7 @@ declare namespace SocketIO {
|
||||
/**
|
||||
* The object used when negociating the handshake
|
||||
*/
|
||||
handshake: {
|
||||
/**
|
||||
* The headers passed along with the request. e.g. 'host',
|
||||
* 'connection', 'accept', 'referer', 'cookie'
|
||||
*/
|
||||
headers: any;
|
||||
|
||||
/**
|
||||
* The current time, as a string
|
||||
*/
|
||||
time: string;
|
||||
|
||||
/**
|
||||
* The remote address of the connection request
|
||||
*/
|
||||
address: string;
|
||||
|
||||
/**
|
||||
* Is this a cross-domain request?
|
||||
*/
|
||||
xdomain: boolean;
|
||||
|
||||
/**
|
||||
* Is this a secure request?
|
||||
*/
|
||||
secure: boolean;
|
||||
|
||||
/**
|
||||
* The timestamp for when this was issued
|
||||
*/
|
||||
issued: number;
|
||||
|
||||
/**
|
||||
* The request url
|
||||
*/
|
||||
url: string;
|
||||
|
||||
/**
|
||||
* Any query string parameters in the request url
|
||||
*/
|
||||
query: any;
|
||||
};
|
||||
|
||||
handshake: Handshake;
|
||||
/**
|
||||
* Sets the 'json' flag when emitting an event
|
||||
*/
|
||||
@@ -629,7 +587,7 @@ declare namespace SocketIO {
|
||||
|
||||
/**
|
||||
* Registers a middleware, which is a function that gets executed for every incoming Packet and receives as parameter the packet and a function to optionally defer execution to the next registered middleware.
|
||||
*
|
||||
*
|
||||
* Errors passed to middleware callbacks are sent as special error packets to clients.
|
||||
*/
|
||||
use( fn: ( packet: Packet, next: (err?: any) => void ) => void ): Socket;
|
||||
@@ -690,6 +648,49 @@ declare namespace SocketIO {
|
||||
compress( compress: boolean ): Socket;
|
||||
}
|
||||
|
||||
interface Handshake {
|
||||
/**
|
||||
* The headers passed along with the request. e.g. 'host',
|
||||
* 'connection', 'accept', 'referer', 'cookie'
|
||||
*/
|
||||
headers: any;
|
||||
|
||||
/**
|
||||
* The current time, as a string
|
||||
*/
|
||||
time: string;
|
||||
|
||||
/**
|
||||
* The remote address of the connection request
|
||||
*/
|
||||
address: string;
|
||||
|
||||
/**
|
||||
* Is this a cross-domain request?
|
||||
*/
|
||||
xdomain: boolean;
|
||||
|
||||
/**
|
||||
* Is this a secure request?
|
||||
*/
|
||||
secure: boolean;
|
||||
|
||||
/**
|
||||
* The timestamp for when this was issued
|
||||
*/
|
||||
issued: number;
|
||||
|
||||
/**
|
||||
* The request url
|
||||
*/
|
||||
url: string;
|
||||
|
||||
/**
|
||||
* Any query string parameters in the request url
|
||||
*/
|
||||
query: any;
|
||||
}
|
||||
|
||||
/**
|
||||
* The interface used when dealing with rooms etc
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user