up
This commit is contained in:
26
TCPClient.go
26
TCPClient.go
@ -132,36 +132,32 @@ func (c *TCPClient) ReadLine() {
|
||||
|
||||
for {
|
||||
message, err := c.Reader.ReadString('\n')
|
||||
message, _ = strings.CutSuffix(message, "\n")
|
||||
message, _ = strings.CutSuffix(message, "\r")
|
||||
if err != nil {
|
||||
Log.Errorf("Error reading message: %s", err)
|
||||
continue
|
||||
}
|
||||
|
||||
Log.Debugf("Received Message: %s", message)
|
||||
|
||||
if strings.Contains(message, Cfg.Cluster.LoginPrompt+"\r\n") || strings.Contains(message, Cfg.Cluster.LoginPrompt+" \r\n") {
|
||||
if strings.Contains(message, Cfg.Cluster.LoginPrompt) {
|
||||
Log.Debug("Found login prompt...sending callsign")
|
||||
c.Write([]byte(c.Login + "\r\n"))
|
||||
time.Sleep(time.Second * 2)
|
||||
c.SetFilters()
|
||||
time.Sleep(time.Second * 1)
|
||||
if Cfg.Cluster.Command != "" {
|
||||
c.WriteString(Cfg.Cluster.Command)
|
||||
}
|
||||
Log.Info("Start receiving spots")
|
||||
} else if strings.Contains(message, "Error reading from server: read tcp") {
|
||||
Log.Error("Disconnected from Telnet Server, reconnecting")
|
||||
c.Close()
|
||||
c.StartClient()
|
||||
} else {
|
||||
ProcessTelnetSpot(spotRe, message, c.SpotChanToFlex, c.SpotChanToHTTPServer, c.Countries)
|
||||
}
|
||||
|
||||
ProcessTelnetSpot(spotRe, message, c.SpotChanToFlex, c.SpotChanToHTTPServer, c.Countries)
|
||||
|
||||
// Send the spot message to TCP server
|
||||
if len(c.TCPServer.Clients) > 0 {
|
||||
if count == 0 {
|
||||
// wait 5 seconds before sending messages to allow the client to connect
|
||||
time.Sleep(time.Second * 5)
|
||||
count++
|
||||
}
|
||||
c.MsgChan <- message
|
||||
}
|
||||
c.MsgChan <- message
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user