コード例 #1
0
ファイル: answer.go プロジェクト: 42MrPiou42/Wibo_OpenProject
func (Data *Data) Manage_Login(request *list.Element, Db *sql.DB, Dlist *devices.All_Devices) (er error) {
	req := request.Value.(*protocol.Request)
	er = nil
	flag := true
	var answer []byte

	if req.Rtype != TYPELOG {
		er = errors.New("Bad type to Manage_Login")
		answer = Data.Manage_ack(TYPELOG, 0, int32(0))
	} else {
		if Data.Device == nil {
			Data.Device, er = Dlist.GetDevice(request, Db, Data.Lst_users)
		}
		if er == nil {
			device := Data.Device.Value.(*devices.Device)
			if len(req.Spec.(protocol.Log).Email) <= 1 {
				Data.Logged = DEFAULTUSER
				Data.User = device.UserDefault
			} else {
				Data.User = Data.Lst_users.Check_user(request, Db, device.Historic)
				if Data.User == nil {
					flag = false
					Data.Logged = DEFAULTUSER
					device.UserSpec = nil
					Data.User = device.UserDefault
				} else {
					Data.Logged = USERLOGGED
					device.UserSpec = Data.User
					device.AddUserSpecOnHistory(Data.User)
				}
			}
		}
		if er != nil {
			answer = Data.Manage_ack(TYPELOG, 0, int32(0))
		} else if flag == false {
			answer = Data.Manage_ack(TYPELOG, 0, int32(2))
		} else {
			answer = Data.Manage_ack(TYPELOG, 0, int32(1))
		}
	}
	Data.Lst_asw.PushBack(answer)
	return er
}
コード例 #2
0
func TestBallon(t *testing.T) {

	var err error

	Lst_users := new(users.All_users)
	Lst_ball := new(ballon.All_ball)
	Lprotocol := new(protocol.Request)
	Ldevices := new(devices.All_Devices)
	myDb := new(db.Env)
	Lst_users.Ulist = list.New()
	Lst_ball.Blist = list.New()
	Db, err := myDb.OpenCo(err)
	Lst_ball.Get_balls(Lst_users, myDb)
	fmt.Println(Db)

	Lprotocol.Coord.Lon = 48.833986
	Lprotocol.Coord.Lat = 2.316045
	// user1 := new(users.User)
	// 	user1.Id = 68
	// 	user1.Mail = "*****@*****.**"
	// 	user1.Log = time.Now()
	// 	user1.Followed = list.New()
	// user2 := new(users.User)
	// 	user1.Id = 68
	// 	user1.Mail = "*****@*****.**"
	// 	user1.Log = time.Now()
	// 	user1.Followed = list.New()
	// user3 := new(users.User)
	// 	user1.Id = 68
	// 	user1.Mail = "*****@*****.**"
	// 	user1.Log = time.Now()
	// 	user1.Followed = list.New()
	// user4 := new(users.User)
	// 	user1.Id = 68
	// 	user1.Mail = "*****@*****.**"
	// 	user1.Log = time.Now()
	// 	user1.Followed = list.New()
	// user5 := new(users.User)
	// 	user1.Id = 68
	// 	user1.Mail = "*****@*****.**"
	// 	user1.Log = time.Now()
	// 	user1.Followed = list.New()
	// user6 := new(users.User)
	// 	user1.Id = 68
	// 	user1.Mail = "*****@*****.**"
	// 	user1.Log = time.Now()
	// 	user1.Followed = list.New()
	// user7 := new(users.User)
	// 	user1.Id = 68
	// 	user1.Mail = "*****@*****.**"
	// 	user1.Log = time.Now()
	// 	user1.Followed = list.New()

	// 	Lst_users.Ulist.PushBack(user1)
	// 	Lst_users.Ulist.PushBack(user1)
	// 	Lst_users.Ulist.PushBack(user1)
	// 	Lst_users.Ulist.PushBack(user1)
	// 	Lst_users.Ulist.PushBack(user1)
	Lst_users.Get_users(myDb.Db)
	Ldevices.Get_devices(Lst_users, myDb)

}