func GetSessionByUID(uid string) *Session {
	if val, ok := sessionsByUID.Load(uid); ok {
		return val.(*Session)
	}
	return nil
}
GetSessionByUID return a session bound to an user id
package session
import (
	"context"
	"encoding/json"
	"net"
	"reflect"
	"sync"
	"sync/atomic"
	"time"
	"github.com/golang/protobuf/proto"
	nats "github.com/nats-io/nats.go"
	"github.com/topfreegames/pitaya/constants"
	"github.com/topfreegames/pitaya/logger"
	"github.com/topfreegames/pitaya/protos"
)
type NetworkEntity interface {
	Push(route string, v interface{}) error
	ResponseMID(ctx context.Context, mid uint, v interface{}, isError ...bool) error
	Close() error
	Kick(ctx context.Context) error
	RemoteAddr() net.Addr
	SendRequest(ctx context.Context, serverID, route string, v interface{}) (*protos.Response, error)
}
var (
	sessionBindCallbacks = make([]func(ctx context.Context, s *Session) error, 0)
	afterBindCallbacks   = make([]func(ctx context.Context, s *Session) error, 0)
	SessionCloseCallbacks = make([]func(s *Session), 0)
	sessionsByUID         sync.Map                 
	sessionsByID          sync.Map                 
	sessionIDSvc          = newSessionIDService()  
	SessionCount int64
)
type HandshakeClientData struct {
	Platform    string `json:"platform"`
	LibVersion  string `json:"libVersion"`
	BuildNumber string `json:"clientBuildNumber"`
	Version     string `json:"clientVersion"`
}
type HandshakeData struct {
	Sys  HandshakeClientData    `json:"sys"`
	User map[string]interface{} `json:"user,omitempty"`
}
type Session struct {
	sync.RWMutex                              
	id                int64                   
	uid               string                  
	lastTime          int64                   
	entity            NetworkEntity           
	data              map[string]interface{}  
	handshakeData     *HandshakeData          
	encodedData       []byte                  
	OnCloseCallbacks  []func()                
	IsFrontend        bool                    
	frontendID        string                  
	frontendSessionID int64                   
	Subscriptions     []*nats.Subscription    
}
type sessionIDService struct {
	sid int64
}
func newSessionIDService() *sessionIDService {
	return &sessionIDService{
		sid: 0,
	}
}
func (c *sessionIDService) sessionID() int64 {
	return atomic.AddInt64(&c.sid, 1)  
}
func New(entity NetworkEntity, frontend bool, UID ...string) *Session {
	s := &Session{
		id:               sessionIDSvc.sessionID(),  
		entity:           entity,
		data:             make(map[string]interface{}),
		handshakeData:    nil,
		lastTime:         time.Now().Unix(),
		OnCloseCallbacks: []func(){},
		IsFrontend:       frontend,
	}
	if frontend {
		sessionsByID.Store(s.id, s)        
		atomic.AddInt64(&SessionCount, 1)  
	}
	if len(UID) > 0 {
		s.uid = UID[0]
	}
	return s
}