Giter VIP home page Giter VIP logo

Comments (8)

panjf2000 avatar panjf2000 commented on June 11, 2024

这个问题主要是 gnet v1 里出现的,因为 v1 有编码器和解码器的功能,导致解码器在识别第一个特殊包的场景中不是很灵活,但是 gnet v2 移除了编码器和解码器,现在整个数据解析逻辑都要放在 OnTraffic() 里了,更加灵活,就没必要再设置一个所谓的 handler 了,用户自己判断一下第一个包然后处理就行了。

from gnet.

gh-translator avatar gh-translator commented on June 11, 2024

🤖 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.

skyw4code avatar skyw4code commented on June 11, 2024

这个问题主要是 gnet v1 里出现的,因为 v1 有编码器和解码器的功能,导致解码器在识别第一个特殊包的场景中不是很灵活,但是 gnet v2 移除了编码器和解码器,现在整个数据解析逻辑都要放在 OnTraffic() 里了,更加灵活,就没必要再设置一个所谓的 handler 了,用户自己判断一下第一个包然后处理就行了。

是~~~
其实纠结的是后面每次数据包来的时候也得都去判断一下,这个很难受...

from gnet.

gh-translator avatar gh-translator commented on June 11, 2024

🤖 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.

panjf2000 avatar panjf2000 commented on June 11, 2024

不需要每次都判断,你用 sync.Once 或者更简单地在 c.Context 里设置一个 bool,第一个包解析完之后就设个标志,下次判断一下这个标志,跳过就行了。

from gnet.

gh-translator avatar gh-translator commented on June 11, 2024

🤖 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.

skyw4code avatar skyw4code commented on June 11, 2024

下次判断一下这个标志,跳过就行了。

emmm... 我说的就是这个判断,这也是判断啊...

from gnet.

gh-translator avatar gh-translator commented on June 11, 2024

🤖 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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.