Skip to content
This repository has been archived by the owner on Jan 13, 2022. It is now read-only.

Send custom packet before kick (CloseConnection) #62

Open
Mellnik opened this issue May 8, 2015 · 4 comments
Open

Send custom packet before kick (CloseConnection) #62

Mellnik opened this issue May 8, 2015 · 4 comments

Comments

@Mellnik
Copy link

Mellnik commented May 8, 2015

I'd like to send a custom packet to a client before kicking them with CloseConnection.
So I put a IMMEDIATE_PRIORITY in my Send function right before CloseConnection but the packet never reaches the client..
So I wonder if there's a way to send some data to the client before kicking them?

@Disintegrate
Copy link

I don't think there is a direct way to guarantee that the packet arrives at the client before the connection is closed. When kicking I just put the client in a queue after sending the kick notification, and wait for a small delay before terminating the connection (100ms should be enough). I also use the 'SetTimeoutTime' function to lower the amount of time I wait for the client to disconnect in case he's not responding.

@Mellnik
Copy link
Author

Mellnik commented May 12, 2015

A queue is possible but also less secure. After doing more research I found out that IMMEDIATE_PRIORITY and CloseConnection with sendNotification = true works.

@Disintegrate
Copy link

I assumed you were already closing your connection with 'sendNotification = true'. On a local network this approach will always work, but when you use it over an Internet connection problems start to pop up.

Assume you have 1% packet loss, this means once every hundred kick attempts the kick message will never arrive at the client. Even if the kick message arrives it's possible it only arrives after the disconnected notification is received, causing it to be dropped. (of course this depends on the ordering channel, reliability and priority settings) So ideally you want to leave some time between sending the kick message and closing the connection (maybe a few times the round trip delay).

The reason I suggested to lower the timeout time is simply to avoid waiting for the full standard configured timeout when trying to kick a non-responsive client. The server will keep on trying to send the disconnect notification reliably until the configured timeout has passed.

@Kiddinglife
Copy link

not sure what you exactly want to solve.A possible solution in my view could be calling the close function in some function called back by client when the closing packets received.

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

3 participants