MCPcopy
hub / github.com/nats-io/nats.go / GetClientID

Method GetClientID

nats.go:6492–6502  ·  view source on GitHub ↗

GetClientID returns the client ID assigned by the server to which the client is currently connected to. Note that the value may change if the client reconnects. This function returns ErrClientIDNotSupported if the server is of a version prior to 1.2.0.

()

Source from the content-addressed store, hash-verified

6490// This function returns ErrClientIDNotSupported if the server is of a
6491// version prior to 1.2.0.
6492func (nc *Conn) GetClientID() (uint64, error) {
6493 nc.mu.RLock()
6494 defer nc.mu.RUnlock()
6495 if nc.isClosed() {
6496 return 0, ErrConnectionClosed
6497 }
6498 if nc.info.CID == 0 {
6499 return 0, ErrClientIDNotSupported
6500 }
6501 return nc.info.CID, nil
6502}
6503
6504// StatusChanged returns a channel on which given list of connection status changes will be reported.
6505// If no statuses are provided, defaults will be used: CONNECTED, RECONNECTING, DISCONNECTED, CLOSED.

Calls 1

isClosedMethod · 0.95