MCPcopy
hub / github.com/tinode/chat / hello

Method hello

server/session.go:734–879  ·  view source on GitHub ↗

Client metadata

(msg *ClientComMessage)

Source from the content-addressed store, hash-verified

732
733// Client metadata
734func (s *Session) hello(msg *ClientComMessage) {
735 var params map[string]any
736 var deviceIDUpdate bool
737
738 if s.ver == 0 {
739 s.ver = parseVersion(msg.Hi.Version)
740 if s.ver == 0 {
741 logs.Warn.Println("s.hello:", "failed to parse version", s.sid)
742 s.queueOut(ErrMalformed(msg.Id, "", msg.Timestamp))
743 return
744 }
745 // Check version compatibility
746 if versionCompare(s.ver, minSupportedVersionValue) < 0 {
747 s.ver = 0
748 s.queueOut(ErrVersionNotSupported(msg.Id, msg.Timestamp))
749 logs.Warn.Println("s.hello:", "unsupported version", s.sid)
750 return
751 }
752
753 params = map[string]any{
754 "ver": currentVersion,
755 "build": store.Store.GetAdapterName() + ":" + buildstamp,
756 "maxMessageSize": globals.maxMessageSize,
757 "maxSubscriberCount": globals.maxSubscriberCount,
758 "minTagLength": minTagLength,
759 "maxTagLength": maxTagLength,
760 "maxTagCount": globals.maxTagCount,
761 "maxFileUploadSize": globals.maxFileUploadSize,
762 "reqCred": globals.validatorClientConfig,
763 "msgDelAge": globals.msgDeleteAge.Seconds(),
764 }
765 if len(globals.iceServers) > 0 {
766 params["iceServers"] = globals.iceServers
767 }
768 if globals.callEstablishmentTimeout > 0 {
769 params["callTimeout"] = globals.callEstablishmentTimeout
770 }
771
772 if s.proto == GRPC {
773 // gRPC client may need server address to be able to fetch large files over http(s).
774 // TODO: add support for fetching files over gRPC, then remove this parameter.
775 params["servingAt"] = globals.servingAt
776 // Report cluster size.
777 if globals.cluster != nil {
778 params["clusterSize"] = len(globals.cluster.nodes) + 1
779 } else {
780 params["clusterSize"] = 1
781 }
782 }
783
784 // Set ua & platform in the beginning of the session.
785 // Don't change them later.
786 s.userAgent = msg.Hi.UserAgent
787 s.platf = msg.Hi.Platform
788 if s.platf == "" {
789 s.platf = platformFromUA(msg.Hi.UserAgent)
790 }
791 // This is a background session. Start a timer.

Callers

nothing calls this directly

Calls 15

queueOutMethod · 0.95
parseVersionFunction · 0.85
ErrMalformedFunction · 0.85
versionCompareFunction · 0.85
ErrVersionNotSupportedFunction · 0.85
platformFromUAFunction · 0.85
userChannelsSubUnsubFunction · 0.85
decodeStoreErrorFunction · 0.85
ErrAuthRequiredReplyFunction · 0.85
ErrCommandOutOfSequenceFunction · 0.85
PrintlnMethod · 0.80
GetAdapterNameMethod · 0.65

Tested by

no test coverage detected