Skip to content
This repository was archived by the owner on Sep 27, 2021. It is now read-only.

Access raw websocket data within middleware #79

Open
makhloughi opened this issue Sep 6, 2019 · 6 comments
Open

Access raw websocket data within middleware #79

makhloughi opened this issue Sep 6, 2019 · 6 comments
Assignees

Comments

@makhloughi
Copy link

Hi there, I'm new with Adonis and it's
websocket library & I need to access sent raw data(packet) & headers from the client in middlewares and channel controllers.
Is there any way to access all of that and modify some headers & add data to packet structure in response?!

Note: channel/topic name is not accessible via middlewares too. Is this a lack?! I need to do some stuff before grant access to channel's controller(without creating named specific middleware for each channel).

I've nothing found in the v4.1 documentation for now. Poorest documentation for such framework I've ever seen, don't hide us things 😁

@thetutlage thetutlage self-assigned this Sep 6, 2019
@thetutlage
Copy link
Member

Will be nice, if you can share some code on what exactly you have tried so far. All theory can lead to the XY problem

@makhloughi
Copy link
Author

makhloughi commented Sep 6, 2019

thanks for your rapid response.
here is my wsHandle method of custom auth middleware(outputs are commented):
`

async wsHandle (ctx, next) {
    console.log('custom Middle Ware was dispatched');//this is working fine
    console.log(ctx.socket.id);//chat#ck07wexgk0000zgv4e3k3cvtr is on the console log
    console.log(ctx.socket.channel);//is null --why?!
}

`

  1. in this custom middleware i wanna do some checks for myself by accessing channel.name & request headers then grant access or refuse connection before reaching the channel controller.
  2. if raw packet object(in this exact form) is accessible, how can i touch it in the middleware or controller?

let me be honest, i wanna access low level data for reading(fields out of the message object) or adding some fields, such as my auth keys, hidden data, etc. to the packet structure & modify response headers in some cases too. can you help me find the handlers?
thanks for your attention & time

@makhloughi
Copy link
Author

as i found, you have no interest to answer this question anymore. such as this link.
we need it Mr Virk! can you help us or not? clear this please.

@makhloughi
Copy link
Author

are you dead?!

@thetutlage
Copy link
Member

No having dinner

@makhloughi
Copy link
Author

Enjoy your meal

@thetutlage thetutlage removed the triage label Nov 5, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants