Esempio n. 1
0
File: flush.go Progetto: hycxa/gonet
//------------------------------------------------ save to db
func _flush(sess *Session) {
	if sess.User != nil {
		sess.User.LastSaveTime = time.Now().Unix()
		user_tbl.Set(sess.User)
		helper.NOTICE(sess.User.Id, sess.User.Name, "data flushed")
	}

	// TODO : save all the data in session
	sess.MarkClean()
}
Esempio n. 2
0
func TestLoginProc(t *testing.T) {
	sess := &Session{}
	sess.MQ = make(chan IPCObject, 100)
	sess.User = &User{Id: 1}
	LoginProc(sess)

	user_tbl.Set(sess.User)
	data_tbl.Set(estates.COLLECTION, sess.Estates)
	data_tbl.Set(samples.COLLECTION, sess.LatencySamples)
}
Esempio n. 3
0
func BenchmarkLoginProc(b *testing.B) {
	for i := 1; i <= b.N; i++ {
		sess := &Session{}
		sess.MQ = make(chan IPCObject, 10)
		sess.User = &User{Id: int32(i)}
		LoginProc(sess)
		user_tbl.Set(sess.User)
		data_tbl.Set(estates.COLLECTION, sess.Estates)
		data_tbl.Set(samples.COLLECTION, sess.LatencySamples)
	}
}
Esempio n. 4
0
//------------------------------------------------ flush all user data
func _flush(sess *Session) {
	user_tbl.Set(sess.User)
	if sess.Estates != nil {
		data_tbl.Set(estates.COLLECTION, sess.Estates)
	}

	if sess.Soldiers != nil {
		data_tbl.Set(soldiers.COLLECTION, sess.Soldiers)
	}

	if sess.Heroes != nil {
		data_tbl.Set(heroes.COLLECTION, sess.Heroes)
	}

	if sess.LatencySamples != nil {
		data_tbl.Set(samples.COLLECTION, sess.LatencySamples)
	}

	sess.LastFlushTime = time.Now().Unix()
	sess.OpCount = 0
}