From fd5f555f363c1808f7f3b0f252cad007efc6f125 Mon Sep 17 00:00:00 2001 From: Marten Seemann Date: Thu, 9 Jul 2020 20:21:48 +0700 Subject: [PATCH] put the session in the packet handler map directly (for client sessions) --- client.go | 37 +------------------------------------ client_test.go | 5 ----- 2 files changed, 1 insertion(+), 41 deletions(-) diff --git a/client.go b/client.go index e56329f4..560d45ad 100644 --- a/client.go +++ b/client.go @@ -44,8 +44,6 @@ type client struct { logger utils.Logger } -var _ packetHandler = &client{} - var ( // make it possible to mock connection ID generation in the tests generateConnectionID = protocol.GenerateConnectionID @@ -266,7 +264,7 @@ func (c *client) dial(ctx context.Context) error { c.version, ) c.mutex.Unlock() - c.packetHandlers.Add(c.srcConnID, c) + c.packetHandlers.Add(c.srcConnID, c.session) errorChan := make(chan error, 1) go func() { @@ -305,36 +303,3 @@ func (c *client) dial(ctx context.Context) error { return nil } } - -func (c *client) handlePacket(p *receivedPacket) { - c.session.handlePacket(p) -} - -func (c *client) shutdown() { - c.mutex.Lock() - defer c.mutex.Unlock() - if c.session == nil { - return - } - c.session.shutdown() -} - -func (c *client) destroy(e error) { - c.mutex.Lock() - defer c.mutex.Unlock() - if c.session == nil { - return - } - c.session.destroy(e) -} - -func (c *client) GetVersion() protocol.VersionNumber { - c.mutex.Lock() - v := c.version - c.mutex.Unlock() - return v -} - -func (c *client) getPerspective() protocol.Perspective { - return protocol.PerspectiveClient -} diff --git a/client_test.go b/client_test.go index b44a7970..077ea378 100644 --- a/client_test.go +++ b/client_test.go @@ -634,9 +634,4 @@ var _ = Describe("Client", func() { Expect(counter).To(Equal(2)) }) }) - - It("tells its version", func() { - Expect(cl.version).ToNot(BeZero()) - Expect(cl.GetVersion()).To(Equal(cl.version)) - }) })