예제 #1
0
func NewBaseServer(
	name string, serverid int, serverType EWormholeType,
	addr string, maxConnections int,
	routePack IRoutePack, wm IWormholeManager) *BaseServer {

	if MAX_CONNECTIONS < maxConnections {
		maxConnections = MAX_CONNECTIONS
	}

	s := &BaseServer{
		Name:            name,
		ServerId:        serverid,
		Addr:            addr,
		ServerType:      serverType,
		MaxConns:        maxConnections,
		Stop_:           false,
		exitChan:        make(chan bool),
		Wormholes:       wm,
		RoutePackHandle: routePack,
	}

	/*
	   if s.RoutePackHandle.GetEndian() == gts.BigEndian {
	       s.endianer = binary.BigEndian
	   } else {
	       s.endianer = binary.LittleEndian
	   }
	*/

	s.idassign = gts.NewIDAssign(s.MaxConns)

	return s
}
예제 #2
0
func NewGuinMaker() *GuinMaker {
	gm := &GuinMaker{
		idassign: gts.NewIDAssign(2<<14 - 1),
		//r :        rand.New(rand.NewSource(time.Now().UnixNano())),
	}

	return gm
}