MCPcopy
hub / github.com/coder/websocket / newConn

Function newConn

conn.go:104–143  ·  view source on GitHub ↗
(cfg connConfig)

Source from the content-addressed store, hash-verified

102}
103
104func newConn(cfg connConfig) *Conn {
105 c := &Conn{
106 subprotocol: cfg.subprotocol,
107 rwc: cfg.rwc,
108 client: cfg.client,
109 copts: cfg.copts,
110 flateThreshold: cfg.flateThreshold,
111
112 br: cfg.br,
113 bw: cfg.bw,
114
115 closed: make(chan struct{}),
116 activePings: make(map[string]chan<- struct{}),
117 onPingReceived: cfg.onPingReceived,
118 onPongReceived: cfg.onPongReceived,
119 }
120
121 c.readMu = newMu(c)
122 c.writeFrameMu = newMu(c)
123
124 c.msgReader = newMsgReader(c)
125
126 c.msgWriter = newMsgWriter(c)
127 if c.client {
128 c.writeBuf = extractBufioWriterBuf(c.bw, c.rwc)
129 }
130
131 if c.flate() && c.flateThreshold == 0 {
132 c.flateThreshold = 128
133 if !c.msgWriter.flateContextTakeover() {
134 c.flateThreshold = 512
135 }
136 }
137
138 runtime.SetFinalizer(c, func(c *Conn) {
139 c.close()
140 })
141
142 return c
143}
144
145// Subprotocol returns the negotiated subprotocol.
146// An empty string means the default protocol.

Callers 5

dialFunction · 0.85
acceptFunction · 0.85

Calls 7

flateMethod · 0.95
closeMethod · 0.95
newMsgReaderFunction · 0.85
newMsgWriterFunction · 0.85
extractBufioWriterBufFunction · 0.85
newMuFunction · 0.70
flateContextTakeoverMethod · 0.45

Used in the wild real call sites across dependent graphs

searching dependent graphs…