hocuspocus icon indicating copy to clipboard operation
hocuspocus copied to clipboard

`connection` can be either Connection or ConnectionConfiguration

Open canadaduane opened this issue 1 year ago • 1 comments

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 avatar May 16 '23 14:05 canadaduane