-
Notifications
You must be signed in to change notification settings - Fork 0
/
footle.go
78 lines (61 loc) · 1.97 KB
/
footle.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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
/**
* Footle the DBGp debugger.
*
* Here we launch go routines for command line UI, HTTP UI, receiving
* messages from DBGp engine and sending DBGp commands to DBGp engine.
*/
package main
import (
"server/cli"
"server/config"
"server/core"
conn "server/core/connection"
"server/dbgp/message"
"server/http"
)
/**
* Launch go routines.
*
* Launch the debugger and its user interfaces.
*
* End execution when the "bye" channel is closed.
*/
func main() {
// Setup command line flags and arguments.
config := config.Get()
// Initializations.
var MsgsForCmdLineUI, MsgsForHTTPUI chan message.Message
CmdsFromUI := make(chan string)
DBGpCmds := make(chan string)
DBGpMessages := make(chan message.Message)
bye := make(chan struct{})
launchUIs(config, &MsgsForCmdLineUI, &MsgsForHTTPUI, CmdsFromUI, bye)
// Talk to DBGp engine.
DBGpConnection := conn.GetConnection()
DBGpConnection.Activate()
go core.RecvMsgsFromDBGpEngine(DBGpConnection, DBGpMessages)
go core.SendCmdsToDBGpEngine(DBGpConnection, DBGpCmds)
// Let Footle deal with all commands from UIs first. Some commands will then
// head for the DBGp engine while some will change Footle's internal state.
go core.ProcessUICmds(CmdsFromUI, DBGpCmds, DBGpMessages, DBGpConnection)
// Process incoming DBGP messages before selectively passing them to the UIs.
go core.ProcessDBGpMessages(DBGpCmds, DBGpMessages, MsgsForCmdLineUI, MsgsForHTTPUI)
<-bye
}
/**
* Launch all user interfaces.
*
* Start the HTTP and/or the Cli interfaces depending on user preferences.
*/
func launchUIs(config config.Config, MsgsForCmdLineUI, MsgsForHTTPUI *chan message.Message, CmdsFromUI chan string, bye chan struct{}) {
if config.HasCmdLine() {
*MsgsForCmdLineUI = make(chan message.Message)
go cli.RunUI(CmdsFromUI, bye)
go cli.UpdateUIStatus(*MsgsForCmdLineUI)
}
if config.HasHTTP() {
*MsgsForHTTPUI = make(chan message.Message)
go http.Listen(CmdsFromUI, config)
go http.TellBrowsers(*MsgsForHTTPUI, config)
}
}