MCPcopy Index your code
hub / github.com/screego/server / newClient

Function newClient

ws/client.go:50–69  ·  view source on GitHub ↗
(conn *websocket.Conn, req *http.Request, read chan ClientMessage, authenticatedUser string, authenticated, trustProxy bool)

Source from the content-addressed store, hash-verified

48}
49
50func newClient(conn *websocket.Conn, req *http.Request, read chan ClientMessage, authenticatedUser string, authenticated, trustProxy bool) *Client {
51 ip := conn.RemoteAddr().(*net.TCPAddr).IP
52 if realIP := req.Header.Get("X-Real-IP"); trustProxy && realIP != "" {
53 ip = net.ParseIP(realIP)
54 }
55
56 client := &Client{
57 conn: conn,
58 info: ClientInfo{
59 Authenticated: authenticated,
60 AuthenticatedUser: authenticatedUser,
61 ID: xid.New(),
62 Addr: ip,
63 Write: make(chan outgoing.Message, 1),
64 },
65 read: read,
66 }
67 client.debug().Msg("WebSocket New Connection")
68 return client
69}
70
71// CloseOnError closes the connection.
72func (c *Client) CloseOnError(code int, reason string) {

Callers 1

UpgradeMethod · 0.85

Calls 2

debugMethod · 0.95
GetMethod · 0.65

Tested by

no test coverage detected