The user-defined data associated with this socket instance. This can be set when the socket is created via Bun.connect({ data: ... }). It can be read or updated at any time.
property data | Bun module | Bun BuildDocsReferenceGuidesBlogDiscord/Bun/TCPSocket/dataPdata BuildDocsReferenceGuidesBlogDiscord /Bun/TCPSocket/dataPdata TCPSocket.datadata: undefined
Search the reference...
/
property
// In a socket handler
function open(socket: Socket: string }>) {
console.log(`Socket opened for user: ${socket.data.userId}`);
socket.data.lastActivity = Date.now(); // Update data
}
Resources
ReferenceDocsGuidesDiscordMerch StoreGitHubBlogToolkit
RuntimePackage managerTest runnerBundlerPackage runnerProject
Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicenseBaked with ❤️ in San Francisco
We're hiring →property data | Bun module | Bun,AI智能索引,全网链接索引,智能导航,网页索引
- The user-defined data associated with this socket instance.
This can be set when the socket is created via `Bun.connect({ data: ... })`.
It can be read or updated at any time.