Esempio n. 1
0
func (tk *Task) Run() error {
	defer utils.DumpStackIfPanic("Task Run")
	core.CoreObject().Waitor.Add(1)
	defer core.CoreObject().Waitor.Done()

	err := tk.DoFunc()
	if err != nil {
		if tk.ErrLimit > 0 && tk.ErrLimit > len(tk.Errlist) {
			tk.Errlist = append(tk.Errlist, &taskerr{t: tk.Next, errinfo: err.Error()})
		}
	}
	return err
}
Esempio n. 2
0
func init() {
	netlib.RegisterFactory(int(protocol.MmoPacketID_PACKET_SC_GATEINFO), netlib.PacketFactoryWrapper(func() interface{} {
		return &protocol.SCGateInfo{}
	}))
	netlib.RegisterHandler(int(protocol.MmoPacketID_PACKET_SC_GATEINFO), netlib.HandlerWrapper(func(s *netlib.Session, pack interface{}) error {
		logger.Trace("receive gateinfo==", pack)
		if sr, ok := pack.(*protocol.SCGateInfo); ok {
			sc := &netlib.SessionConfig{
				Id:           int(sr.GetSrvId()),
				Type:         int(sr.GetSrvType()),
				Ip:           sr.GetIp(),
				Port:         int(sr.GetPort()),
				AuthKey:      sr.GetAuthKey(),
				WriteTimeout: 30,
				ReadTimeout:  30,
				IdleTimeout:  30,
				MaxDone:      20,
				MaxPend:      20,
				MaxPacket:    1024,
				RcvBuff:      1024,
				SndBuff:      1024,
				IsClient:     true,
				NoDelay:      true,
				FilterChain:  []string{"session-filter-trace", "session-filter-auth"},
			}
			sc.Init()
			err := netlib.Connect(core.CoreObject(), sc)
			if err != nil {
				logger.Warn("connect server failed err:", err)
			}
		}
		return nil
	}))
}
Esempio n. 3
0
func (mssrl *MyServerSessionRegisteListener) OnRegiste(*netlib.Session) {
	logger.Trace("MyServerSessionRegisteListener.OnRegiste")
	tnp := &transact.TransNodeParam{
		Tt:     protocol.TxTrace,
		Ot:     transact.TransOwnerType(2),
		Oid:    202,
		AreaID: 1,
	}

	tNode := transact.DTCModule.StartTrans(tnp, nil, transact.DefaultTransactTimeout)
	if tNode != nil {
		tNode.Go(core.CoreObject())
	}
}
Esempio n. 4
0
func New(s *basic.Object, c Callable, n CompleteNotify, name ...string) *Task {
	t := &Task{
		s:       s,
		c:       c,
		n:       n,
		r:       make(chan interface{}, 1),
		tCreate: time.Now(),
	}
	if len(name) != 0 {
		t.name = name[0]
	}
	if s == nil {
		t.s = core.CoreObject()
	}

	return t
}
Esempio n. 5
0
func (this *transactCoordinater) ProcessTransStart(parentTnp, myTnp *TransNodeParam, ud interface{}, timeout time.Duration) bool {
	if this.quit {
		logger.Warn("transactCoordinater.processTransStart find shutdowning, parent=", parentTnp, " selfparam=", myTnp)
		return false
	}
	tnode := this.createTransNode(myTnp, ud, timeout)
	if tnode == nil {
		return false
	}

	tnode.ParentTnp = parentTnp
	tnode.ownerObj = core.CoreObject()
	ret := tnode.execute(ud)
	if ret != TransExeResult_Success {
		return false
	}
	return true
}
Esempio n. 6
0
func SendStartNetIoService(sc *SessionConfig) bool {
	return core.CoreObject().SendCommand(&startIoService{sc: sc}, false)
}