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

Catch exception on frame send #1

Open
gacardinal opened this issue Jan 11, 2019 · 1 comment
Open

Catch exception on frame send #1

gacardinal opened this issue Jan 11, 2019 · 1 comment
Assignees

Comments

@gacardinal
Copy link
Owner

In WebSocketClient.cs, on line 150, the bytes are sent to the socket in a try {} catch () {} statement and for now simply re-throws a new exception to the client of the library with the original exception as inner exception. However, it shouldn't be the responsibility of the user to wrap the call to Cli.SendFrames() in a try {} catch () {} statement.

The reason SendFrames() is a part of the WebSocketClient class and not the WebSocketServer class is that sometimes, other internal classes may need to send control frames but only have a reference to the client object and not the server. Also, I think it makes more sense from a semantic standpoint.

To go around this, a 'proxy' method could be implemented in the WebSocketServer class that would receive a cli and a frame as arguments. It would then call the cli.SendFrame() method in a try {} catch () {} statement. When catching an error, the WebSocketServer will be responsible for executing any logic to remove the client from the active sockets and raise an OnError event so the client is notified of the exception and that the client for which it occured is no longer active

@gacardinal gacardinal self-assigned this Jan 11, 2019
@shelbyyyyy
Copy link

@Gaboik Is this still relevant? If not, please delete/close the issue. :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants