-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmessage.go
46 lines (42 loc) · 911 Bytes
/
message.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main
import (
"encoding/json"
//"io/ioutil"
//"os"
//"os/user"
//"path/filepath"
//"sort"
//"strconv"
//"github.com/asticode/go-astichartjs"
"github.com/asticode/go-astilectron"
"github.com/asticode/go-astilectron-bootstrap"
)
// handleMessages handles messages
func handleMessages(_ *astilectron.Window, m bootstrap.MessageIn) (payload interface{}, err error) {
switch m.Name {
case "explore":
// Unmarshal payload
var path string
if len(m.Payload) > 0 {
// Unmarshal payload
if err = json.Unmarshal(m.Payload, &path); err != nil {
payload = err.Error()
return
}
}
case "login":
var user string
var pass string
if len (m.Payload) > 0 {
if err = json.Unmarshal(m.Payload, &user); err != nil {
payload = err.Error()
return
}
if err = json.Unmarshal(m.Payload, &pass); err != nil {
payload = err.Error()
return
}
}
}
return
}