Comments (8)
这个问题主要是 gnet v1 里出现的,因为 v1 有编码器和解码器的功能,导致解码器在识别第一个特殊包的场景中不是很灵活,但是 gnet v2 移除了编码器和解码器,现在整个数据解析逻辑都要放在 OnTraffic()
里了,更加灵活,就没必要再设置一个所谓的 handler 了,用户自己判断一下第一个包然后处理就行了。
from gnet.
🤖 Non-English text detected, translating...
This problem mainly occurs in gnet v1, because v1 has the functions of encoder and decoder, resulting in the decoder not being very flexible in the scenario of identifying the first special packet, but gnet v2 removes the encoder and decoder. Now the entire data parsing logic will be placed in OnTraffic()
, which is more flexible. There is no need to set up a so-called handler. The user can just judge the first package and process it.
from gnet.
这个问题主要是 gnet v1 里出现的,因为 v1 有编码器和解码器的功能,导致解码器在识别第一个特殊包的场景中不是很灵活,但是 gnet v2 移除了编码器和解码器,现在整个数据解析逻辑都要放在
OnTraffic()
里了,更加灵活,就没必要再设置一个所谓的 handler 了,用户自己判断一下第一个包然后处理就行了。
是~~~
其实纠结的是后面每次数据包来的时候也得都去判断一下,这个很难受...
from gnet.
🤖 Non-English text detected, translating...
This problem mainly occurs in gnet v1, because v1 has the functions of encoder and decoder, resulting in the decoder not being very flexible in the scenario of identifying the first special packet, but gnet v2 removes the encoder and decoder , now the entire data parsing logic must be placed in
OnTraffic()
, which is more flexible. There is no need to set up a so-called handler. The user can just judge the first package and then process it.
Yes~~~
In fact, the struggle is that every time a data packet comes, it has to be judged. This is very uncomfortable...
from gnet.
不需要每次都判断,你用 sync.Once
或者更简单地在 c.Context
里设置一个 bool,第一个包解析完之后就设个标志,下次判断一下这个标志,跳过就行了。
from gnet.
🤖 Non-English text detected, translating...
You don’t need to judge every time. You can use sync.Once
or simply set a bool in c.Context
. After the first package is parsed, set a flag. Next time, judge this flag and skip it. That's it.
from gnet.
下次判断一下这个标志,跳过就行了。
emmm... 我说的就是这个判断,这也是判断啊...
from gnet.
🤖 Non-English text detected, translating...
Judge this sign next time and just skip it.
-
- ! This is the judgment I am talking about. This is also a judgment...
from gnet.
Related Issues (20)
- [Bug]: Calling Dial() in version 2.4 of Windows 10 will block HOT 4
- [Question]: I would like to verify whether this problem in the screenshot will cause the memory of the service to slowly increase. HOT 1
- [Feature]: support edge-triggered I/O
- [Question]: Is the netpoll v1 version defaulting to horizontal triggering, and the V2 version defaulting to edge triggering? HOT 15
- [Bug]: fatal error: concurrent map read and map write HOT 1
- Inconsistent behaviors with SO_REUSEPORT on Linux and *BSD HOT 7
- Don't use SO_REUSEPORT on Unix domain sockets HOT 1
- Don't disable SO_REUSEPORT on DragonFlyBSD HOT 1
- [Question]: gnet client works not as expected even tho i did it according to the api ref HOT 1
- [Bug]: GNET client not working as expected HOT 4
- [Bug]: example gnet for echo tcp uses too much memory HOT 7
- [Bug]: Read returns io.ErrShortBuffer on closed connection HOT 7
- [Question]: How to shut down the started tcp server and turn off port listening? HOT 2
- [Question]: When using io.CopyBuffer(), do you need to call Flush to send the data? HOT 2
- [Bug]: Discard() panic HOT 17
- [Feature]: `io_uring` support HOT 6
- [Question]: there's gnet https server now, how to use gnet https client? HOT 1
- UDP FD handle is not released HOT 1
- [Question]: The redis server service implemented using gnet has too many read tcp i/o timeouts in the production environment. HOT 6
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 gnet.