This commit is contained in:
@@ -26,8 +26,8 @@ type ReceivedMessage struct {
|
|||||||
Location meowlib.Location
|
Location meowlib.Location
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckForMessages checks for messages on a single server
|
// PollServer checks for messages on a single server
|
||||||
func CheckForMessages(storage_path string, job *client.RequestsJob, timeout int, longPoll bool) (int, string, error) {
|
func PollServer(storage_path string, job *client.RequestsJob, timeout int, longPoll bool) (int, string, error) {
|
||||||
|
|
||||||
count := 0
|
count := 0
|
||||||
|
|
||||||
@@ -111,8 +111,8 @@ func SaveCheckJobs() (string, error) {
|
|||||||
return "", nil
|
return "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// ReadMessage
|
// ConsumeInboxFile
|
||||||
func ReadMessage(messageFilename string) ([]string, []string, string, error) {
|
func ConsumeInboxFile(messageFilename string) ([]string, []string, string, error) {
|
||||||
|
|
||||||
messagesOverview := []string{}
|
messagesOverview := []string{}
|
||||||
filenames := []string{}
|
filenames := []string{}
|
||||||
@@ -150,7 +150,7 @@ func ReadMessage(messageFilename string) ([]string, []string, string, error) {
|
|||||||
//fmt.Println("From:", usermsg.From)
|
//fmt.Println("From:", usermsg.From)
|
||||||
//jsonUserMessage, _ := json.Marshal(usermsg)
|
//jsonUserMessage, _ := json.Marshal(usermsg)
|
||||||
//fmt.Println(string(jsonUserMessage))
|
//fmt.Println(string(jsonUserMessage))
|
||||||
peer = client.GetConfig().GetIdentity().Peers.GetFromPublicKey(usermsg.From)
|
//peer = client.GetConfig().GetIdentity().Peers.GetFromPublicKey(usermsg.From)
|
||||||
|
|
||||||
// detach files
|
// detach files
|
||||||
if usermsg.Files != nil {
|
if usermsg.Files != nil {
|
||||||
@@ -177,6 +177,8 @@ func ReadMessage(messageFilename string) ([]string, []string, string, error) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, "ReadMessage: StoreMessage", err
|
return nil, nil, "ReadMessage: StoreMessage", err
|
||||||
}
|
}
|
||||||
|
filenames = []string{}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -189,8 +191,8 @@ func ReadMessage(messageFilename string) ([]string, []string, string, error) {
|
|||||||
return messagesOverview, filenames, "", nil
|
return messagesOverview, filenames, "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// CheckForMessages checks for messages on a single server
|
// LongPollAllSerevrJobs checks for messages on a all servers defived in job file
|
||||||
func LongPollForMessages(storage_path string, jobs []client.RequestsJob, timeout int, longPoll bool) (int, string, error) {
|
func LongPollAllSerevrJobs(storage_path string, jobs []client.RequestsJob, timeout int, longPoll bool) (int, string, error) {
|
||||||
|
|
||||||
// Channel to collect results
|
// Channel to collect results
|
||||||
resultChan := make(chan int, len(jobs))
|
resultChan := make(chan int, len(jobs))
|
||||||
@@ -207,7 +209,7 @@ func LongPollForMessages(storage_path string, jobs []client.RequestsJob, timeout
|
|||||||
defer wg.Done()
|
defer wg.Done()
|
||||||
|
|
||||||
// Long-polling call to the server
|
// Long-polling call to the server
|
||||||
cnt, _, err := CheckForMessages(storage_path, &job, timeout, true)
|
cnt, _, err := PollServer(storage_path, &job, timeout, true)
|
||||||
|
|
||||||
if err == nil && cnt > 0 {
|
if err == nil && cnt > 0 {
|
||||||
select {
|
select {
|
||||||
|
|||||||
@@ -47,7 +47,7 @@ func BuildCallMessage(videodata *meowlib.VideoData, srvuid string, peer_uid stri
|
|||||||
|
|
||||||
usermessage.Status.AnswerToUuid = replyToUid
|
usermessage.Status.AnswerToUuid = replyToUid
|
||||||
|
|
||||||
return messageBuildPostprocess(usermessage, srvuid, peer)
|
return messageBuildPackAndStore(usermessage, srvuid, peer)
|
||||||
}
|
}
|
||||||
|
|
||||||
func BuildCancelCallMessage() {
|
func BuildCancelCallMessage() {
|
||||||
|
|||||||
@@ -5,7 +5,7 @@ import (
|
|||||||
"forge.redroom.link/yves/meowlib/client"
|
"forge.redroom.link/yves/meowlib/client"
|
||||||
)
|
)
|
||||||
|
|
||||||
func messageBuildPostprocess(msg *meowlib.UserMessage, srvuid string, peer *client.Peer) ([]byte, string, error) {
|
func messageBuildPackAndStore(msg *meowlib.UserMessage, srvuid string, peer *client.Peer) ([]byte, string, error) {
|
||||||
// Get the message server
|
// Get the message server
|
||||||
srv, err := client.GetConfig().GetIdentity().MessageServers.LoadServer(srvuid)
|
srv, err := client.GetConfig().GetIdentity().MessageServers.LoadServer(srvuid)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
@@ -30,7 +30,7 @@ func messageBuildPostprocess(msg *meowlib.UserMessage, srvuid string, peer *clie
|
|||||||
return data, "", nil
|
return data, "", nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func PrepareUserMessage(message string, srvuid string, peer_uid string, replyToUid string, filelist []string) ([]byte, string, error) {
|
func CreateUserMessage(message string, srvuid string, peer_uid string, replyToUid string, filelist []string) ([]byte, string, error) {
|
||||||
|
|
||||||
peer := client.GetConfig().GetIdentity().Peers.GetFromUid(peer_uid)
|
peer := client.GetConfig().GetIdentity().Peers.GetFromUid(peer_uid)
|
||||||
|
|
||||||
@@ -47,7 +47,7 @@ func PrepareUserMessage(message string, srvuid string, peer_uid string, replyToU
|
|||||||
}
|
}
|
||||||
usermessage.Status.AnswerToUuid = replyToUid
|
usermessage.Status.AnswerToUuid = replyToUid
|
||||||
|
|
||||||
return messageBuildPostprocess(usermessage, srvuid, peer)
|
return messageBuildPackAndStore(usermessage, srvuid, peer)
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -29,7 +29,6 @@ func StoreMessage(peer *Peer, usermessage *meowlib.UserMessage, filenames []stri
|
|||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
file.Close()
|
file.Close()
|
||||||
peer.DbIds = append(peer.DbIds, dbid)
|
|
||||||
sqliteDatabase, err := sql.Open("sqlite3", filepath.Join(cfg.StoragePath, identity.Uuid, dbid+GetConfig().DbSuffix))
|
sqliteDatabase, err := sql.Open("sqlite3", filepath.Join(cfg.StoragePath, identity.Uuid, dbid+GetConfig().DbSuffix))
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return err
|
return err
|
||||||
|
|||||||
Reference in New Issue
Block a user