MCPcopy
hub / github.com/ContainerSSH/ContainerSSH / Close

Method Close

agentprotocol/server.go:77–100  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

75}
76
77func (c *Connection) Close() error {
78 c.lock.Lock()
79
80 switch c.state {
81 case CONNECTION_STATE_WAITINIT:
82 fallthrough
83 case CONNECTION_STATE_STARTED:
84 c.state = CONNECTION_STATE_WAITCLOSE
85 c.stateCond.Broadcast()
86 c.lock.Unlock()
87 packet := Packet{
88 Type: PACKET_CLOSE_CONNECTION,
89 ConnectionId: c.id,
90 }
91 return c.ctx.writePacket(&packet)
92 case CONNECTION_STATE_WAITCLOSE:
93 c.lock.Unlock()
94 return nil
95 case CONNECTION_STATE_CLOSED:
96 c.lock.Unlock()
97 return nil
98 }
99 return fmt.Errorf("unknown state")
100}
101
102func (c *Connection) CloseImm() error {
103 c.lock.Lock()

Callers

nothing calls this directly

Calls 2

writePacketMethod · 0.80
ErrorfMethod · 0.65

Tested by

no test coverage detected