Skip to content

Commit cc4113d

Browse files
Update gitignore and remove vendor dir
1 parent 17635a4 commit cc4113d

File tree

5 files changed

+109
-2
lines changed

5 files changed

+109
-2
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,6 @@ dist/*
4949

5050
tutorial/bin/*
5151

52-
release
52+
release
53+
54+
vendor
Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
package connection
2+
3+
import (
4+
"io"
5+
"os"
6+
"time"
7+
8+
"github.com/miketheprogrammer/go-thrust/commands"
9+
. "github.com/miketheprogrammer/go-thrust/common"
10+
)
11+
12+
// Single Connection
13+
//var conn net.Conn
14+
var StdIn io.WriteCloser
15+
var StdOut io.ReadCloser
16+
17+
type In struct {
18+
Commands chan *commands.Command
19+
Quit chan int
20+
}
21+
type Out struct {
22+
CommandResponses chan commands.CommandResponse
23+
Errors chan error
24+
}
25+
26+
var in In
27+
var out Out
28+
29+
/*
30+
Initializes threads with Channel Structs
31+
Opens Connection
32+
*/
33+
func InitializeThreads() error {
34+
//c, err := net.Dial(proto, address)
35+
//conn = c
36+
37+
in = In{
38+
Commands: make(chan *commands.Command),
39+
Quit: make(chan int),
40+
}
41+
42+
out = Out{
43+
CommandResponses: make(chan commands.CommandResponse),
44+
Errors: make(chan error),
45+
}
46+
47+
go Reader(&out, &in)
48+
go Writer(&out, &in)
49+
50+
return nil
51+
}
52+
53+
func GetOutputChannels() *Out {
54+
return &out
55+
}
56+
57+
func GetInputChannels() *In {
58+
return &in
59+
}
60+
61+
func GetCommunicationChannels() (*Out, *In) {
62+
return GetOutputChannels(), GetInputChannels()
63+
}
64+
65+
func Reader(out *Out, in *In) {
66+
67+
for {
68+
select {
69+
case quit := <-in.Quit:
70+
Log.Errorf("Connection Reader Received a Quit message from somewhere ... Exiting Now")
71+
os.Exit(quit)
72+
default:
73+
time.Sleep(time.Microsecond * 100)
74+
break
75+
}
76+
}
77+
78+
}
79+
80+
func Writer(out *Out, in *In) {
81+
var targetId uint = 0
82+
for {
83+
select {
84+
case command := <-in.Commands:
85+
ActionId += 1
86+
command.ID = ActionId
87+
response := commands.CommandResponse{}
88+
switch command.Action {
89+
case "create":
90+
targetId += 1
91+
response.ID = command.ID
92+
response.Action = "reply"
93+
response.Result = commands.ReplyResult{
94+
TargetID: targetId,
95+
}
96+
out.CommandResponses <- response
97+
case "call":
98+
response.ID = command.ID
99+
response.Action = "reply"
100+
out.CommandResponses <- response
101+
}
102+
}
103+
time.Sleep(time.Microsecond * 100)
104+
}
105+
}

public/index.html

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
<body>
77
<h1 class="header">
88
Welcome to the Thrust Demo.
9-
<iframe id="docview" width="800px" height="768px">
9+
<iframe id="docview" src="https://github.com/miketheprogrammer/go-thrust/tree/master/doc">
1010
</iframe>
1111
</h2>
1212
</body>

vendor/darwin/x64/README.md

Whitespace-only changes.

vendor/linux/x64/README.md

Whitespace-only changes.

0 commit comments

Comments
 (0)