func Main(
tcpDataStreamCh chan<- Segment,
clientRequestCh <-chan datatypes.ClientRequest,
)
Main is the entrypoint for the tcphttpclient package. Requires tcpDataStreamCh which it outputs the received TCP data and clientRequestCh, which it accepts requests from users.
func connectTCP(tcpDataStream chan<- Segment, stop <-chan bool)
connectTCP Creates an connection to the MEA database, and receives int32s. Puts those into the tcpDataStream channel. If a message is received on the stop channel, the function returns after finishing the current batch.
func httpMain(
clientRequestCh <-chan datatypes.ClientRequest,
startStopTcpCh chan<- startStopTcp,
)
httpMain defines the entrypoint for the http client, which sends START/STOP to the MEA server. Requires clientRequestCh, which it accepts Start or Stop, defining to send a start or stop request to the MEA server. Requires startStopTcpCh, which it uses to start/stop the tcp connection.
func requestRemoteServer(start bool, sampleRate int, segmentLength int) bool
requestRemoteServer sends a Start / Stop post request to the MEA HTTP server.
func tcpMain(
segmentCh chan<- Segment,
startStopTcpCh <-chan startStopTcp,
)
tcpMain defines the entrypoint for the TCP connection between the client and the MEA server. Requires segmentCh, which it sends out received TCP data and startStopTcpCh, which controls when to start and stop the TCP connection.
Segment is a raw MEA segment from the MEA server
type Segment [60 * config.SegmentLength]int32
requestOptions is a struct representing the data which is sent to the MEA Server.
type requestOptions struct {
SampleRate int `json:"sample_rate""`
SegmentLength int `json:"segment_length""`
}
type startStopTcp int