poll interval time
This commit is contained in:
snoop 2017-06-07 14:05:42 +09:00
parent 1d838d813d
commit 6c3b7483db

View File

@ -6,7 +6,7 @@ import (
"git.loafle.net/overflow/overflow_proxy_service/proxy/apikey"
"git.loafle.net/overflow/overflow_proxy_service/proxy/keystore"
"git.loafle.net/overflow/overflow_proxy_service/proxy/noauthagent"
"encoding/json"
)
@ -14,6 +14,18 @@ type InitializeServerImpl struct {
}
func testPollInterval(types string) float64 {
var defaultTime float64 = 10
if types == "CheckAuth" {
return defaultTime
}
return defaultTime;
}
func (s *InitializeServerImpl) StartAgent(c context.Context, info *pb.AgentInfo) (*pb.InitResponse, error) {
output := &pb.InitResponse{}
@ -51,7 +63,8 @@ func (s *InitializeServerImpl) RequestTempKey(c context.Context, info *pb.ReqTem
ti.TempKey = key
//FIXME:: check Poll intervar
//ti.PollInterval
time := testPollInterval("CheckAuth")
ti.PollInterval = time
return ti, nil
}
@ -65,7 +78,7 @@ func (s *InitializeServerImpl) CheckAuth(c context.Context, info *pb.TempKey) (*
as := &pb.AuthStatus{}
as.Type = pb.AuthStatus_AUTH_WAIT
as.Type = pb.AuthStatus_WAIT
str, err := ns.CheckAuth(info.Value)
@ -73,18 +86,10 @@ func (s *InitializeServerImpl) CheckAuth(c context.Context, info *pb.TempKey) (*
return as, err
}
//FIXME auth type
res := ""
err = json.Unmarshal([]byte(str), &res)
if err != nil {
return as , nil
}
if res == "ACCEPT" {
as.Type = pb.AuthStatus_AUTH_ACCEPT
} else if res == "REFUSE" {
as.Type = pb.AuthStatus_AUTH_REFUSE
if str == pb.AuthStatus_REFUSE.String() {
as.Type = pb.AuthStatus_ACCEPT
} else if str == pb.AuthStatus_REFUSE.String() {
as.Type = pb.AuthStatus_REFUSE
}
return as, nil