Skip to content

Commit

Permalink
offline Indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
nanu-c committed Mar 11, 2020
1 parent 4654cfb commit b3f2a7f
Show file tree
Hide file tree
Showing 7 changed files with 277 additions and 212 deletions.
3 changes: 3 additions & 0 deletions app/ui/dialogs.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,6 @@ func ShowError(err error) {
webserver.ShowError(err.Error())
log.Errorln("[axolotl] error: ", err.Error())
}
func ClearError() {
webserver.ClearError()
}
5 changes: 5 additions & 0 deletions app/webserver/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,11 @@ func ShowError(errorMessage string) {
sendError(client, errorMessage)
}
}
func ClearError() {
for client := range clients {
sendError(client, "")
}
}

func sendAttachment(attachment SendAttachmentMessage) error {
// log.Infoln("[axolotl] send attachment ", attachment.Path)
Expand Down
16 changes: 8 additions & 8 deletions app/webserver/helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ func sendChatList(client *websocket.Conn) {
// defer mu.Unlock()
err = client.WriteMessage(websocket.TextMessage, *message)
if err != nil {
log.Println("[textsecure] send error chat list ", err)
log.Println("[axolotl] send error chat list ", err)
return
}
}
Expand Down Expand Up @@ -62,7 +62,7 @@ func sendCurrentChat(client *websocket.Conn, s *store.Session) {
// defer mu.Unlock()
err = client.WriteMessage(websocket.TextMessage, *message)
if err != nil {
log.Println("[textsecure] send error current chat ", err)
log.Println("[axolotl] send error current chat ", err)
return
}

Expand Down Expand Up @@ -100,7 +100,7 @@ func sendContactList(client *websocket.Conn) {
// mu.Lock()
// defer mu.Unlock()
if err := client.WriteMessage(websocket.TextMessage, *message); err != nil {
log.Println("[textsecure] send error contact list ", err)
log.Println("[axolotl] send error contact list ", err)
return
}
}
Expand All @@ -119,7 +119,7 @@ func sendDeviceList(client *websocket.Conn) {
// mu.Lock()
// defer mu.Unlock()
if err := client.WriteMessage(websocket.TextMessage, *message); err != nil {
log.Println("[textsecure] send error device list", err)
log.Println("[axolotl] send error device list", err)
return
}
}
Expand Down Expand Up @@ -214,7 +214,7 @@ func sendMoreMessageList(client *websocket.Conn, id string, lastId string) {
// mu.Lock()
// defer mu.Unlock()
if err := client.WriteMessage(websocket.TextMessage, *message); err != nil {
log.Println("[textsecure] send error more message list", err)
log.Println("[axolotl] send error more message list", err)
return
}
}
Expand All @@ -234,7 +234,7 @@ func sendIdentityInfo(client *websocket.Conn, myId []byte, theirId []byte) {
// mu.Lock()
// defer mu.Unlock()
if err := client.WriteMessage(websocket.TextMessage, *message); err != nil {
log.Println("[textsecure] send error identity info", err)
log.Println("[axolotl] send error identity info", err)
return
}

Expand Down Expand Up @@ -282,7 +282,7 @@ func SetGui() {
// mu.Lock()
// defer mu.Unlock()
if err := client.WriteMessage(websocket.TextMessage, *message); err != nil {
log.Println("[textsecure] send error set gui", err)
log.Println("[axolotl] send error set gui", err)
return
}
}
Expand All @@ -305,7 +305,7 @@ func sendConfig(client *websocket.Conn) {
// mu.Lock()
// defer mu.Unlock()
if err := client.WriteMessage(websocket.TextMessage, *message); err != nil {
log.Println("[textsecure] send config", err)
log.Println("[axolotl] send config", err)
return
}
}
32 changes: 21 additions & 11 deletions app/worker/textsecureapi.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import (
"strings"
"time"

"github.com/signal-golang/textsecure"
"github.com/nanu-c/axolotl/app/config"
"github.com/nanu-c/axolotl/app/contact"
"github.com/nanu-c/axolotl/app/handler"
Expand All @@ -18,6 +17,7 @@ import (
"github.com/nanu-c/axolotl/app/settings"
"github.com/nanu-c/axolotl/app/store"
"github.com/nanu-c/axolotl/app/ui"
"github.com/signal-golang/textsecure"
log "github.com/sirupsen/logrus"
)

Expand Down Expand Up @@ -167,20 +167,30 @@ func RunBackend() {
//Load Messages

// Make sure to use names not numbers in session titles

badHandshake := false
for {
if !isEncrypted {
if !sessionStarted {
log.Debugf("[axolotl] Start Session after Decryption")
startSession()
ui.ClearError()
if !badHandshake {
if !isEncrypted {
if !sessionStarted {
log.Debugf("[axolotl] Start Session after Decryption")
startSession()

}
if err := textsecure.StartListening(); err != nil {
log.Debugln(err)
if err.Error() == "websocket: bad handshake" {
badHandshake = true
}
ui.ShowError(err)
}
}
if err := textsecure.StartListening(); err != nil {
log.Debugln(err)
ui.ShowError(err)
}
time.Sleep(3 * time.Second)
} else {
ui.ShowError(errors.New("Your registration is faulty"))
time.Sleep(10 * time.Minute)

}
time.Sleep(3 * time.Second)

}
}
Expand Down
Loading

0 comments on commit b3f2a7f

Please sign in to comment.