Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

connection can be either Connection or ConnectionConfiguration #606

Open
canadaduane opened this issue May 16, 2023 · 1 comment
Open

connection can be either Connection or ConnectionConfiguration #606

canadaduane opened this issue May 16, 2023 · 1 comment

Comments

@canadaduane
Copy link
Contributor

canadaduane commented May 16, 2023

The problem I am facing
It's a bit confusing that there is a connection key in various hook payloads that is either a Connection instance or a ConnectionConfiguration object. Both are quite different:

Connection

  webSocket: WebSocket
  context: any
  document: Document
  pingInterval: NodeJS.Timeout
  pongReceived = true
  request: HTTPIncomingMessage
  timeout: number
  callbacks: any
  socketId: string
  lock: AsyncLock
  readOnly: Boolean
  logger: Debugger

ConnectionConfiguration

  readOnly: boolean
  requiresAuthentication: boolean
  isAuthenticated: boolean

But they appear to be the same at first glance:

onConnect({connection}) {
  // connection is ConnectionConfiguration
})

beforeHandleMessage({connection}) {
  // connection is Connection
})

The solution I would like
It would be great if ConnectionConfiguration were always connectionConfig and Connection were always connection.

@canadaduane
Copy link
Contributor Author

I should add some context. I need to access the Connection object from the connected hook. I'm thinking about adding a PR to include it in the connectedPayload; however, connected already includes ConnectionConfiguration at a key called connection.

(At an even higher level of context: I am trying to add a custom "awareness" implementation, and need access to the websocket directly).

@janthurau janthurau reopened this May 20, 2023
janthurau added a commit that referenced this issue Oct 19, 2023
…redis, we shouldnt run onStoreDocument hooks; refs #730, refs #696, refs #606
janthurau added a commit that referenced this issue Oct 19, 2023
…redis, we shouldnt run onStoreDocument hooks; refs #730, refs #696, refs #606 (#733)
@janthurau janthurau mentioned this issue Jan 4, 2024
TalhaASiddiqi pushed a commit to educative/hocuspocus that referenced this issue Feb 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants