Skip to content

Add chat example #174

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

Closed
svycka opened this issue Dec 2, 2019 · 12 comments · Fixed by #190
Closed

Add chat example #174

svycka opened this issue Dec 2, 2019 · 12 comments · Fixed by #190
Labels

Comments

@svycka
Copy link

svycka commented Dec 2, 2019

Hello @nhooyr,
maybe you could add chat example something like https://github.com/gorilla/websocket/tree/master/examples/chat would be easier to compare both implementations and also would serve as documentation.

@nhooyr nhooyr added the docs label Dec 2, 2019
@nhooyr
Copy link
Contributor

nhooyr commented Dec 2, 2019

https://github.com/gorilla/websocket/tree/master/examples/chat would be easier to compare both implementations and also would serve as documentation.

I feel like the echo example covers the library well while still being light weight. The gorilla chat example is much more involved.

If you feel the echo example along with the comparison in the README does not suffice, then we can explore this.

@nhooyr nhooyr changed the title Chat example Add chat example Dec 2, 2019
@svycka
Copy link
Author

svycka commented Dec 2, 2019

I think chat example covers a lot more. And yes echo example shows basic usage quite well. But still something like chat example as this a common use case for websocket and easy to understand.

@nhooyr nhooyr removed the needs-info label Dec 2, 2019
@nhooyr
Copy link
Contributor

nhooyr commented Dec 2, 2019

Fair enough.

@nhooyr
Copy link
Contributor

nhooyr commented Dec 6, 2019

My plan is to just remove the echo example and turn it into a full fledged chat example.

@svycka
Copy link
Author

svycka commented Dec 9, 2019

@nhooyr not sure why you want to remove it. Why it's bad keeping both? But if you think this way just remove it.

@GustavoCaso
Copy link

GustavoCaso commented Dec 24, 2019

Hi!!

For the past days, I have been working on a chat CLI written in go and using this WebSocket library. I'm not a very experience go developer, but I wanted to learn more and also use WebSockets, which I haven't had the chance to do at my work.

I'm more than happy to go over my example, and if it's good, we can port it as documentation to the library.
Also, I'm happy to work on improving so any issue or PR is welcome.

Here is the repo https://github.com/GustavoCaso/go-chat-websockets

Is missing a README and how to use it, but I plan on keep adding more logic into it. Also, I plan on writing a blog post to help other developers.

Congrats on the library @nhooyr 🎉

@izzymg
Copy link

izzymg commented Jan 25, 2020

I wrote a wrapper using nhooyr/websocket as well - sockparty which is very easy to turn into a chat with a few lines.

@nhooyr
Copy link
Contributor

nhooyr commented Jan 25, 2020

@GustavoCaso

I'm more than happy to go over my example, and if it's good, we can port it as documentation to the library.
Is missing a README and how to use it, but I plan on keep adding more logic into it. Also, I plan on writing a blog post to help other developers.

That's awesome, please do.

I'll take care of this issue myself though soon as I have similar code already written. I'll add a link to your code and @izzymg's though in the README or wiki.

@nhooyr nhooyr added this to the v1.7.0 milestone Jan 26, 2020
nhooyr added a commit that referenced this issue Feb 17, 2020
@nhooyr
Copy link
Contributor

nhooyr commented Feb 17, 2020

Added in #190

Needs docs but you can easily run with go run . in example-chat subdirectory and visit the URL printed.

nhooyr added a commit that referenced this issue Feb 17, 2020
@nhooyr nhooyr removed this from the v1.8.0 milestone Feb 17, 2020
@nerg4l
Copy link

nerg4l commented Apr 14, 2020

@nhooyr In the current chat example you use a /publish endpoint that accepts POST requests to broadcast a message. Wouldn't it make sense to "publish" the messages on WebSocket instead of sending a request to an endpoint?

@nhooyr
Copy link
Contributor

nhooyr commented Apr 14, 2020

@nhooyr In the current chat example you use a /publish endpoint that accepts POST requests to broadcast a message. Wouldn't it make sense to "publish" the messages on WebSocket instead of sending a request to an endpoint?

It would work as well but I made it an endpoint so you could publish messages via curl easily. Will document this decision better.

@nhooyr
Copy link
Contributor

nhooyr commented Apr 15, 2020

Fixed in #225

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

Successfully merging a pull request may close this issue.

5 participants