„client.go“ löschen
This commit is contained in:
parent
78b1d57e18
commit
4a60c94000
53
client.go
53
client.go
@ -1,53 +0,0 @@
|
||||
package proxy
|
||||
|
||||
import (
|
||||
"crypto/tls"
|
||||
"fmt"
|
||||
"net/url"
|
||||
"time"
|
||||
|
||||
"github.com/gorilla/websocket"
|
||||
)
|
||||
|
||||
var connection *websocket.Conn
|
||||
|
||||
// proxy-client
|
||||
func Start_client(v string, w string) {
|
||||
var err error
|
||||
|
||||
for {
|
||||
|
||||
u := url.URL{Scheme: "wss", Host: v, Path: "/ws/" + w}
|
||||
|
||||
dialer := websocket.DefaultDialer
|
||||
dialer.TLSClientConfig = &tls.Config{
|
||||
InsecureSkipVerify: true,
|
||||
}
|
||||
|
||||
fmt.Println("Connect to node", v, "using wallet address", w)
|
||||
connection, _, err = websocket.DefaultDialer.Dial(u.String(), nil)
|
||||
if err != nil {
|
||||
time.Sleep(5 * time.Second)
|
||||
fmt.Println(err)
|
||||
continue
|
||||
}
|
||||
|
||||
for {
|
||||
msg_type, recv_data, err := connection.ReadMessage()
|
||||
if msg_type != websocket.TextMessage || err != nil {
|
||||
break
|
||||
} else {
|
||||
fmt.Println(string(recv_data))
|
||||
//edit_blob(recv_data)
|
||||
go SendTemplatesToNode(recv_data)
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
func SendToDaemon(buffer []byte) {
|
||||
connection.SetWriteDeadline(time.Now().Add(100 * time.Millisecond))
|
||||
connection.WriteMessage(websocket.TextMessage, buffer)
|
||||
return
|
||||
}
|
Loading…
Reference in New Issue
Block a user