Comments (7)
For opening:
wsc, err := upgrader.Upgrade(...)
if err !=nil {
...
return
}
// on open here
or register open handler by upgrader.OnOpen
For closing:
register close handler by upgrader.OnClose
You don't need to check the state of the ws conn when you use it everytime.
from nbio.
I want to make new connection and insure the previous websocket Should be closed, when I renew the older websocket thats why I need to check the webscocket is closed or not.
If you are not exporting isClosed Variable can you please make a function that exports the boolean value for the websocket
from nbio.
I think your way is not correct, that's useless to export isClosed coz:
- before OnClose is called it's healthy
- when OnClose is called, you know that it's closed now
That's why I said you don't need to check it's state.
from nbio.
I know when we call conn.close it closes the stream but in order to renew the websocket I will again do conn.close on the closed channel but in that case i will get error, So I need to ensure the websocket is closed or not before closing the channel also I dont want to make 2 same stream at any moment.
from nbio.
You don't need to re-create it when it's healthy!
You should re-create a new conn when OnClose.
Why do you want to re-create it when it's healthy?
Even you want to re-create a new conn when the old one is still healthy, you just need to close the old one and create the new one, you don't need to care about whether it returns err when you close the old one!
from nbio.
This issue is stale because it has been open for 30 days with no activity.
from nbio.
This issue was closed because it has been inactive for 14 days since being marked as stale.
from nbio.
Related Issues (20)
- 如何增加序列化和反序列化的函数? HOT 3
- how to use with so reuseport option for the http example? HOT 3
- one more question. thx for the prompt reply, how well does it scale as a client? HOT 7
- just tested the performance of nbio tcp https on multicore system. it's great! but... how to do h2? HOT 1
- am i asking for a lot? pushing for tcp performance and nbios hit the mark but... HOT 18
- curious about the "total success" HOT 28
- how to increase the eventloop from the tls server example? HOT 5
- only 2,000 req/s with redis client example but using tls server example modification, i can get 25,000 req/s. what's wrong? HOT 2
- 请教大佬,在很短的时间里,向同一个conn推送多次数据 HOT 8
- 使用udp发送数据,会存在丢包! HOT 14
- Retract v1.5.4 HOT 6
- how to set so reuseport option for server? HOT 3
- 1.5.6 仍可能存在潜在bug HOT 31
- What is the principle of realizing 10 million connections to a single server? HOT 3
- WS客户端发送超高压缩率内容,可导致服务器OOM HOT 15
- onClose 没有调用 HOT 2
- InsecureSkipVerify=false的时候,无法进行TLS连接 HOT 7
- 请教下关于二进制数据压缩的问题 HOT 3
- LetsEncrypt HOT 2
- 大佬有交流群吗 HOT 4
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from nbio.