tcp server 用于给andriod 客户端定时发送消息
fix
liuxiaolong
2019-11-01 a7602018176ee34e055a2877c1b54bd0c950440d
extend/config/config.go
@@ -1 +1,37 @@
package config
import (
   "github.com/spf13/viper"
   "log"
)
type server []ServerInfo
type ServerInfo struct {
   ServerId string `mapstructure: "serverId"`
   ServerIp string `mapstructure: "serverIp"`
   VideoPort string   `mapstructure: "videoPort"`
   NgxIp string  `mapstructure: "ngxIp"`
   NgxPort string   `mapstructure: "ngxPort"`
}
var serverList = &server{}
var ServerMap = make(map[string]string,0)
var NgxMap = make(map[string]string,0)
func Init(env string) {
   var err error
   viper.SetConfigType("yaml")
   viper.SetConfigName(env)
   viper.AddConfigPath("./config/")
   err = viper.ReadInConfig()
   if err != nil {
      log.Fatal("error on parsing configuration file")
   }
   viper.UnmarshalKey("server", serverList)
   for _,s :=range *serverList {
      si := s
      ServerMap[si.ServerId] = "http://"+si.ServerIp+":"+si.VideoPort+"/getRecordVideoPath"
      NgxMap[si.ServerId] = "http://"+si.NgxIp+":"+si.NgxPort+"/videosource"
   }
}