add reconnect to websocket, add get world json object
This commit is contained in:
@@ -11,41 +11,57 @@ import (
|
||||
)
|
||||
|
||||
func (conf *FoundryHttpRequest) GetSessionId() error {
|
||||
getResp, err := http.Get(fmt.Sprintf("http://%s%s", conf.Host, AuthPath))
|
||||
path := fmt.Sprintf("http://%s%s", conf.Host, AuthPath)
|
||||
|
||||
req, err := http.NewRequest("GET", path, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
_, err = conf.SetSessionTokenFromHeader(getResp.Header)
|
||||
client := &http.Client{Jar: conf.Jar}
|
||||
_, err = client.Do(req)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
fmt.Printf("%v\n", conf.Jar)
|
||||
|
||||
_, err = conf.SetSessionTokenFromHeader()
|
||||
return err
|
||||
}
|
||||
|
||||
func (conf *FoundryHttpRequest) GetSessionToken() (bool, error) {
|
||||
req, err := http.NewRequest("GET", fmt.Sprintf("http://%s%s", conf.Host, AuthPath), nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
// func (conf *FoundryHttpRequest) GetSessionToken() (bool, error) {
|
||||
// req, err := http.NewRequest("GET", fmt.Sprintf("http://%s%s", conf.Host, AuthPath), nil)
|
||||
// if err != nil {
|
||||
// return false, err
|
||||
// }
|
||||
|
||||
header := http.Header{}
|
||||
header.Set("Cookie", fmt.Sprintf("session=%s", conf.SessionID))
|
||||
header.Set("Connection", "keep-alive")
|
||||
header.Set("Host", conf.Host)
|
||||
header.Set("Origin", fmt.Sprintf("http://%s", conf.Host))
|
||||
header.Set("Referer", fmt.Sprintf("http://%s%s", conf.Host, AuthPath))
|
||||
// header := http.Header{}
|
||||
// header.Set("Cookie", fmt.Sprintf("session=%s", conf.SessionID))
|
||||
// header.Set("Connection", "keep-alive")
|
||||
// header.Set("Host", conf.Host)
|
||||
// header.Set("Origin", fmt.Sprintf("http://%s", conf.Host))
|
||||
// header.Set("Referer", fmt.Sprintf("http://%s%s", conf.Host, AuthPath))
|
||||
|
||||
req.Header = header
|
||||
client := &http.Client{}
|
||||
// req.Header = header
|
||||
// client := &http.Client{Jar: conf.Jar}
|
||||
|
||||
resp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
// resp, err := client.Do(req)
|
||||
// if err != nil {
|
||||
// return false, err
|
||||
// }
|
||||
|
||||
return conf.SetSessionTokenFromHeader(resp.Header)
|
||||
}
|
||||
// return conf.SetSessionTokenFromHeader(resp.Header)
|
||||
// }
|
||||
|
||||
func (conf *FoundryHttpRequest) GetStatus() (*json_model.Status, error) {
|
||||
getResp, err := http.Get(fmt.Sprintf("http://%s/api/status", conf.Host))
|
||||
req, err := http.NewRequest("GET", fmt.Sprintf("http://%s/api/status", conf.Host), nil)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
|
||||
client := &http.Client{Jar: conf.Jar}
|
||||
getResp, err := client.Do(req)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -64,3 +80,22 @@ func (conf *FoundryHttpRequest) GetStatus() (*json_model.Status, error) {
|
||||
}
|
||||
return &status, nil
|
||||
}
|
||||
|
||||
func (conf *FoundryHttpRequest) GetGame() (bool, error) {
|
||||
req, err := http.NewRequest("GET", fmt.Sprintf("http://%s%s", conf.Host, GamePath), nil)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
header := conf.GetRequestHeader(GamePath)
|
||||
|
||||
req.Header = *header
|
||||
client := &http.Client{Jar: conf.Jar}
|
||||
|
||||
_, err = client.Do(req)
|
||||
if err != nil {
|
||||
return false, err
|
||||
}
|
||||
|
||||
return true, nil
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user