func (c *_Conn) onConnect(clientID []byte) (uid.ID, *types.Error) {
	start := time.Now()
	defer log.ErrLogger.Debug().Str("context", "conn.onConnect").Int64("duration", time.Since(start).Nanoseconds()).Msg("")
	var clientid = uid.ID{}
	if clientID != nil && len(clientID) > c.service.mac.Overhead() {
		if contract, ok := c.service.cache.Load(crypto.SignatureToUint32(clientID[crypto.EpochSize:crypto.MessageOffset])); ok {
			clientid, err := uid.CachedClientID(contract.(uint32))
			if err != nil {
				return nil, types.ErrUnauthorized
			}
			return clientid, nil
		}
	}

	clientid, err := uid.Decode(clientID, c.service.mac)

	if err != nil {
		clientid, err = uid.NewClientID(1)
		if err != nil {
			return nil, types.ErrUnauthorized
		}

		return clientid, types.ErrInvalidClientID
	}

	//do not cache primary client Id
	if !clientid.IsPrimary() {
		cid := []byte(clientid.Encode(c.service.mac))
		c.service.cache.LoadOrStore(crypto.SignatureToUint32(cid[crypto.EpochSize:crypto.MessageOffset]), clientid.Contract())
	}

	return clientid, nil
}
// onConnect is a handler for Connect events.
onConnect is a handler for Connect events.
// onConnect is a handler for Connect events .
func (c *_Conn) onConnect(clientID []byte) (uid.ID, *types.Error) {
	start := time.Now()
	defer log.ErrLogger.Debug().Str("context", "conn.onConnect").Int64("duration", time.Since(start).Nanoseconds()).Msg("")
	var clientid = uid.ID{}
	if clientID != nil && len(clientID) > c.service.mac.Overhead() {
		if contract, ok := c.service.cache.Load(crypto.SignatureToUint32(clientID[crypto.EpochSize:crypto.MessageOffset])); ok {
			clientid, err := uid.CachedClientID(contract.(uint32))
			if err != nil {
				return nil, types.ErrUnauthorized
			}
			return clientid, nil
		}
	}
	clientid, err := uid.Decode(clientID, c.service.mac)
	if err != nil {
		clientid, err = uid.NewClientID(1)
		if err != nil {
			return nil, types.ErrUnauthorized
		}
		return clientid, types.ErrInvalidClientID
	}
	if !clientid.IsPrimary() {
		cid := []byte(clientid.Encode(c.service.mac))
		c.service.cache.LoadOrStore(crypto.SignatureToUint32(cid[crypto.EpochSize:crypto.MessageOffset]), clientid.Contract())
	}
	return clientid, nil
}
func ( c * _Conn ) onConnect ( clientID [ ] byte ) ( uid . ID , * types . Error ) { start := time . Now ( ) defer log . ErrLogger . Debug ( ) . Str ( " " , " " ) . Int64 ( " " , time . Since ( start ) . Nanoseconds ( ) ) . Msg ( " " ) var clientid = uid . ID { } if clientID != nil && len ( clientID ) > c . service . mac . Overhead ( ) { if contract , ok := c . service . cache . Load ( crypto . SignatureToUint32 ( clientID [ crypto . EpochSize : crypto . MessageOffset ] ) ) ; ok { clientid , err := uid . CachedClientID ( contract . ( uint32 ) ) if err != nil { return nil , types . ErrUnauthorized } return clientid , nil } } clientid , err := uid . Decode ( clientID , c . service . mac ) if err != nil { clientid , err = uid . NewClientID ( 1 ) if err != nil { return nil , types . ErrUnauthorized } return clientid , types . ErrInvalidClientID } if ! clientid . IsPrimary ( ) { cid := [ ] byte ( clientid . Encode ( c . service . mac ) ) c . service . cache . LoadOrStore ( crypto . SignatureToUint32 ( cid [ crypto . EpochSize : crypto . MessageOffset ] ) , clientid . Contract ( ) ) } return clientid , nil }
onConnect is a handler for Connect events.
onConnect is a handler for Connect events .
//do not cache primary client Id