| "io/ioutil" | "io/ioutil" | ||||
| "log" | "log" | ||||
| "os" | "os" | ||||
| "time" | |||||
| ) | ) | ||||
| //chat state that we might be use for collecting infomation from user | //chat state that we might be use for collecting infomation from user | ||||
| } | } | ||||
| //we don't check Expire, we give the caller full control on | //we don't check Expire, we give the caller full control on | ||||
| //how to deal wiht expired session | //how to deal wiht expired session | ||||
| //check whether state is for the correct openID and procedure | |||||
| if result.OpenID != openID { | |||||
| err = errors.New("Error: State for " + openID + " is actually for " + result.OpenID) | |||||
| return | |||||
| } | |||||
| if result.Procedure != procedure { | |||||
| err = errors.New("Error: Proecdure for " + procedure + " is actually for " + result.Procedure) | |||||
| return | |||||
| } | |||||
| return | return | ||||
| } | } | ||||
| func processProcedureState(state chatState) (err error) { | func processProcedureState(state chatState) (err error) { | ||||
| //send what we need to send | //send what we need to send | ||||
| if isExpired(state.Expire) { | if isExpired(state.Expire) { | ||||
| return errors.New("State has expired " + stae.Name) | |||||
| return errors.New("State has expired " + state.Name) | |||||
| } | } | ||||
| //mark we have sent. | //mark we have sent. | ||||
| func initTestEcho(openid string) (r chatState) { | func initTestEcho(openid string) (r chatState) { | ||||
| r.Name = openid | r.Name = openid | ||||
| r.Expire = 0 | |||||
| r.Expire = int32(time.Now().Unix() + 100) | |||||
| return | return | ||||
| } | } |