func (ctx *Ctx) init() { ctx.Object = basic.NewObject(ObjId_RootId, "root", basic.Options{ MaxDone: 1024, QueueBacklog: 1024, }, nil) ctx.Object.Waitor = utils.NewWaitor() ctx.UserData = ctx }
func newTcpAcceptor(e *NetEngine, sc *SessionConfig) *TcpAcceptor { a := &TcpAcceptor{ e: e, sc: sc, quit: false, mapSessions: make(map[int]*TcpSession), waitor: utils.NewWaitor(), } a.init() return a }
func newTcpConnector(e *NetEngine, sc *SessionConfig) *TcpConnector { c := &TcpConnector{ sc: sc, e: e, s: nil, connChan: make(chan net.Conn, 2), reaper: make(chan ISession, 1), waitor: utils.NewWaitor(), } ConnectorMgr.registeConnector(c) return c }
func newTcpSession(id int, conn net.Conn, sc *SessionConfig, scl SessionCloseListener) *TcpSession { s := &TcpSession{ conn: conn, } s.Session.Id = id s.Session.sc = sc s.Session.scl = scl s.Session.createTime = time.Now() s.Session.waitor = utils.NewWaitor() s.init() return s }
func newWsConnector(e *NetEngine, sc *SessionConfig) *WsConnector { c := &WsConnector{ sc: sc, e: e, s: nil, connChan: make(chan *websocket.Conn, 2), reaper: make(chan ISession, 1), waitor: utils.NewWaitor(), dialer: websocket.Dialer{ ReadBufferSize: sc.RcvBuff, WriteBufferSize: sc.SndBuff, }, } ConnectorMgr.registeConnector(c) return c }
func newWsAcceptor(e *NetEngine, sc *SessionConfig) *WsAcceptor { a := &WsAcceptor{ e: e, sc: sc, quit: false, mapSessions: make(map[int]*WsSession), waitor: utils.NewWaitor(), upgrader: websocket.Upgrader{ ReadBufferSize: sc.RcvBuff, WriteBufferSize: sc.SndBuff, CheckOrigin: func(r *http.Request) bool { return true }, }, } a.init() return a }