Skip to content

能否支持自动匹配客户端版本 (version 1,2) #94

@josh-chan

Description

@josh-chan

看了一下代码,不是很有信心能改对:

--- a/session.go
+++ b/session.go
@@ -325,10 +325,11 @@ func (s *Session) recvLoop() {
                // read header first
                if _, err := io.ReadFull(s.conn, hdr[:]); err == nil {
                        atomic.StoreInt32(&s.dataReady, 1)
-                       if hdr.Version() != byte(s.config.Version) {
+                       if !(hdr.Version() == byte(1) || hdr.Version() == byte(2)) {
                                s.notifyProtoError(ErrInvalidProtocol)
                                return
                        }
+                       s.config.Version = int(hdr.Version())
                        sid := hdr.StreamID()
                        switch hdr.Cmd() {
                        case cmdNOP:

server 能否通过这样自动适配客户端的协议版本?
@xtaci

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions