30 lines
615 B
Go
30 lines
615 B
Go
|
|
// Package realtimedata define real time data operation functions
|
||
|
|
package realtimedata
|
||
|
|
|
||
|
|
import (
|
||
|
|
"context"
|
||
|
|
"fmt"
|
||
|
|
|
||
|
|
"modelRT/network"
|
||
|
|
)
|
||
|
|
|
||
|
|
// RealTimeDataChan define channel of real time data receive
|
||
|
|
var RealTimeDataChan chan network.RealTimeDataReceiveRequest
|
||
|
|
|
||
|
|
func init() {
|
||
|
|
RealTimeDataChan = make(chan network.RealTimeDataReceiveRequest, 100)
|
||
|
|
}
|
||
|
|
|
||
|
|
// ReceiveChan define func of real time data receive and process
|
||
|
|
func ReceiveChan(ctx context.Context) {
|
||
|
|
for {
|
||
|
|
select {
|
||
|
|
case <-ctx.Done():
|
||
|
|
return
|
||
|
|
case realTimeData := <-RealTimeDataChan:
|
||
|
|
fmt.Println(realTimeData.PayLoad.ComponentID)
|
||
|
|
default:
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|