Beispiel #1
0
func NewConfiguration(codePath string) *Configuration {
	b, err := ioutil.ReadFile(RispPathHelper.StandardizingPath(codePath))
	if err != nil {
		fmt.Println(err)
		return nil
	}

	var result map[string]interface{}
	_, err1 := plist.Unmarshal(b, &result)
	if err1 != nil {
		fmt.Println(err1)
		return nil
	}
	code, ok := result[RispRemoteControllerPath].(string)
	if ok {
		c := &Configuration{plist: &result, Code: code}
		return c
	}
	return nil
}
Beispiel #2
0
func main () {
	configuration := RispRemoteInit.NewConfiguration("Risp.plist")
	if configuration != nil {
		code, err := ioutil.ReadFile(RispPathHelper.StandardizingPath(configuration.Code));
		if err != nil {
			configuration.Code = ""
		} else {
			configuration.Code = string(code)
		}
	}
	fmt.Println(configuration)
	runtime.GOMAXPROCS(256)
	reg := make(chan *websocket.Conn)
	unreg := make(chan *websocket.Conn)
	messageChan := make(chan Message)
	go server(reg, unreg, messageChan, configuration)
	go dispatch(reg, unreg, messageChan, configuration)

	fmt.Println("running...")
	
	reader := bufio.NewReader(os.Stdin)
	for {
		message, err := reader.ReadString('\n')
		if err == nil {
			message = message[:len(message) - 1]	// remove \n

			fmt.Println("input code: ", message)
			if message == "(exit)" {
				fmt.Println("goodbye")
				break
			}
			messageChan <- Message{message}
		} else {
			fmt.Println("error ->", err)
		}
	}
}