Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Server - close a connection #751

Unanswered
Dexter0-0 asked this question in Q&A
Discussion options

I tried to find a way for the web sockets server to close a connection with a certain client if a condition is met and did not find how, any ideas on how i could implement this?

Below is a code snippet of exactly what i would like to accomplish

void ServerEventHandler(uint8_t ClientID, WStype_t Event, uint8_t * Payload, size_t Length)
{
 switch(Event)
 {
 case WStype_CONNECTED:
 if(LedsServer.remoteIP(ClientID) == <<DESIRED KNOWN LOCAL IP>>)
 {
 HandleNewConnection(Payload, Length);
 }
 else
 {
 // forcfully close the connection with <ClientID>
 }
 break;
 }
}
You must be logged in to vote

Replies: 1 comment

Comment options

You should be able to use this function void disconnect(uint8_t num); num is the client number
I found this in the server header file which list all functions and data types.

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet

AltStyle によって変換されたページ (->オリジナル) /