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
|
||||
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())
|
||||
defer cancel()
|
||||
@ -203,7 +203,7 @@ func LongPollForMessages(storage_path string, jobs []*client.RequestsJob, timeou
|
||||
|
||||
for _, job := range jobs {
|
||||
wg.Add(1)
|
||||
go func(job *client.RequestsJob) {
|
||||
go func(job client.RequestsJob) {
|
||||
defer wg.Done()
|
||||
|
||||
for {
|
||||
@ -211,7 +211,7 @@ func LongPollForMessages(storage_path string, jobs []*client.RequestsJob, timeou
|
||||
case <-ctx.Done():
|
||||
return
|
||||
default:
|
||||
cnt, _, err := CheckForMessages(storage_path, job, timeout, true)
|
||||
cnt, _, err := CheckForMessages(storage_path, &job, timeout, true)
|
||||
if err != nil {
|
||||
continue // Optionally handle/log error
|
||||
}
|
||||
|
@ -276,7 +276,7 @@ func (id *Identity) generateRandomHiddenStuff() {
|
||||
type BackgroundJob struct {
|
||||
RootPublic string `json:"root_public,omitempty"`
|
||||
Device meowlib.KeyPair `json:"device,omitempty"`
|
||||
Jobs []*RequestsJob `json:"jobs,omitempty"`
|
||||
Jobs []RequestsJob `json:"jobs,omitempty"`
|
||||
}
|
||||
|
||||
type RequestsJob struct {
|
||||
@ -284,8 +284,8 @@ type RequestsJob struct {
|
||||
LookupKeys []meowlib.KeyPair `json:"lookup_keys,omitempty"`
|
||||
}
|
||||
|
||||
func (id *Identity) GetRequestJobs() []*RequestsJob {
|
||||
var list []*RequestsJob
|
||||
func (id *Identity) GetRequestJobs() []RequestsJob {
|
||||
var list []RequestsJob
|
||||
srvs := map[string]*RequestsJob{}
|
||||
// get all servers
|
||||
servers, err := id.MessageServers.LoadAllServers()
|
||||
@ -320,7 +320,7 @@ func (id *Identity) GetRequestJobs() []*RequestsJob {
|
||||
// build list
|
||||
for _, srv := range srvs {
|
||||
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 //
|
||||
/////////////////////////////////////
|
||||
MyFirstFriend := Me.Peers[0]
|
||||
peers, _ := Me.Peers.GetPeers()
|
||||
MyFirstFriend := peers[0]
|
||||
textmessage := "Hello friend!"
|
||||
// Creating User message
|
||||
usermessage, err := MyFirstFriend.BuildSimpleUserMessage([]byte(textmessage))
|
||||
|
Reference in New Issue
Block a user