示例#1
0
文件: main.go 项目: chikilov/goserver
func writeInput(conn *net.TCPConn) {
	fmt.Print("Enter username: "******"username": string(username)})
	if err != nil {
		fmt.Println("It is not property name")
		return
	}
	err = common.WriteMsg(conn, string(str))
	if err != nil {
		log.Println(err)
	}
	fmt.Println("Enter text: ")
	for {
		text, err := reader.ReadString('\n')
		if err != nil {
			log.Fatal(err)
		}
		err = common.WriteMsg(conn, username+": "+text)
		if err != nil {
			log.Println(err)
		}
	}
}
示例#2
0
文件: main.go 项目: chikilov/goserver
func broadcast(newCon netCon, msg string) {
	for i := range netCons {
		if netCons[i].isHandShakeing {
			err := common.WriteMsg(netCons[i].connection, msg)
			if err != nil {
				log.Println(err)
			}
		}
	}
}