change array of pointer to array of requestjobs
This commit is contained in:
@ -192,7 +192,7 @@ func ReadMessage(messageFilename string) ([]string, []string, string, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// CheckForMessages checks for messages on a single server
|
// CheckForMessages checks for messages on a single server
|
||||||
func LongPollForMessages(storage_path string, jobs []*client.RequestsJob, timeout int, longPoll bool) (int, string, error) {
|
func LongPollForMessages(storage_path string, jobs []client.RequestsJob, timeout int, longPoll bool) (int, string, error) {
|
||||||
|
|
||||||
ctx, cancel := context.WithCancel(context.Background())
|
ctx, cancel := context.WithCancel(context.Background())
|
||||||
defer cancel()
|
defer cancel()
|
||||||
@ -203,7 +203,7 @@ func LongPollForMessages(storage_path string, jobs []*client.RequestsJob, timeou
|
|||||||
|
|
||||||
for _, job := range jobs {
|
for _, job := range jobs {
|
||||||
wg.Add(1)
|
wg.Add(1)
|
||||||
go func(job *client.RequestsJob) {
|
go func(job client.RequestsJob) {
|
||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
for {
|
for {
|
||||||
@ -211,7 +211,7 @@ func LongPollForMessages(storage_path string, jobs []*client.RequestsJob, timeou
|
|||||||
case <-ctx.Done():
|
case <-ctx.Done():
|
||||||
return
|
return
|
||||||
default:
|
default:
|
||||||
cnt, _, err := CheckForMessages(storage_path, job, timeout, true)
|
cnt, _, err := CheckForMessages(storage_path, &job, timeout, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
continue // Optionally handle/log error
|
continue // Optionally handle/log error
|
||||||
}
|
}
|
||||||
|
@ -276,7 +276,7 @@ func (id *Identity) generateRandomHiddenStuff() {
|
|||||||
type BackgroundJob struct {
|
type BackgroundJob struct {
|
||||||
RootPublic string `json:"root_public,omitempty"`
|
RootPublic string `json:"root_public,omitempty"`
|
||||||
Device meowlib.KeyPair `json:"device,omitempty"`
|
Device meowlib.KeyPair `json:"device,omitempty"`
|
||||||
Jobs []*RequestsJob `json:"jobs,omitempty"`
|
Jobs []RequestsJob `json:"jobs,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
type RequestsJob struct {
|
type RequestsJob struct {
|
||||||
@ -284,8 +284,8 @@ type RequestsJob struct {
|
|||||||
LookupKeys []meowlib.KeyPair `json:"lookup_keys,omitempty"`
|
LookupKeys []meowlib.KeyPair `json:"lookup_keys,omitempty"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (id *Identity) GetRequestJobs() []*RequestsJob {
|
func (id *Identity) GetRequestJobs() []RequestsJob {
|
||||||
var list []*RequestsJob
|
var list []RequestsJob
|
||||||
srvs := map[string]*RequestsJob{}
|
srvs := map[string]*RequestsJob{}
|
||||||
// get all servers
|
// get all servers
|
||||||
servers, err := id.MessageServers.LoadAllServers()
|
servers, err := id.MessageServers.LoadAllServers()
|
||||||
@ -320,7 +320,7 @@ func (id *Identity) GetRequestJobs() []*RequestsJob {
|
|||||||
// build list
|
// build list
|
||||||
for _, srv := range srvs {
|
for _, srv := range srvs {
|
||||||
if len(srv.LookupKeys) > 0 {
|
if len(srv.LookupKeys) > 0 {
|
||||||
list = append(list, srv)
|
list = append(list, *srv)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -85,7 +85,8 @@ func TestEndToEnd(t *testing.T) {
|
|||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
// Create a message to that friend //
|
// Create a message to that friend //
|
||||||
/////////////////////////////////////
|
/////////////////////////////////////
|
||||||
MyFirstFriend := Me.Peers[0]
|
peers, _ := Me.Peers.GetPeers()
|
||||||
|
MyFirstFriend := peers[0]
|
||||||
textmessage := "Hello friend!"
|
textmessage := "Hello friend!"
|
||||||
// Creating User message
|
// Creating User message
|
||||||
usermessage, err := MyFirstFriend.BuildSimpleUserMessage([]byte(textmessage))
|
usermessage, err := MyFirstFriend.BuildSimpleUserMessage([]byte(textmessage))
|
||||||
|
Reference in New Issue
Block a user