gnet-io / gnet-examples

Examples of gnet
MIT License
245 stars 77 forks source link

Add gnet example websocket for v2 #13

Closed whiteCcinn closed 2 years ago

panjf2000 commented 2 years ago

Thank you for this work, I have one question though: Did you run some tests against this example to verify if it's functional?

whiteCcinn commented 2 years ago

Thank you for your reply. In the development environment, I have tested chrome websocket-client extension, and it seems that there is basically no major problem. Or do you need to provide unit tests? @panjf2000

panjf2000 commented 2 years ago

I just want to make sure that this example works properly, so it's better to be verified by either unit tests or integration tests and I think the way you tested it looks good to me.

it seems that there is basically no major problem

I notice that you said "no major problem", are there any minor problems with it? @whiteCcinn

whiteCcinn commented 2 years ago

The reason I say "no major problem" is because I simply test for "text" type message.

A complete set of examples you know is not easy to implement, but this is just an example and I think this can be refined over time.

I think it's possible to provide a websocket-client.go as a basis for testing? If you agree with this plan, I will add it later.

@panjf2000

panjf2000 commented 2 years ago

The reason I say "no major problem" is because I simply test for "text" type message.

A complete set of examples you know is not easy to implement, but this is just an example and I think this can be refined over time.

I think it's possible to provide a websocket-client.go as a basis for testing? If you agree with this plan, I will add it later.

@panjf2000

Yes, please add the websocket_client.go.

whiteCcinn commented 2 years ago

The code has been updated to add a websocket_client.go for review @panjf2000

whiteCcinn commented 2 years ago

websocket-client.go

image

websocket-server.go

image

whiteCcinn commented 2 years ago

The above problems have been fixed. If there are any more questions you can review them.

@panjf2000