import "bufio"
import "strings"
-var cmdHandler = map[string]func([]string,string) {
+var cmdHandler = map[string]func([]string,string,*bufio.ReadWriter ) {
"test":handleCmdTest,
}
fmt.Printf("Received: %v\n", line)
tokens:=strings.Fields(line)
remainStr:=strings.Join(tokens[1:]," ")
- handleCmd(tokens,remainStr)
+ handleCmd(tokens,remainStr,client)
}
}
-func handleCmd(tokens []string, remainStr string) {
+func handleCmd(tokens []string, remainStr string,client * bufio.ReadWriter) {
cmd:=tokens[0]
func_ptr,present := cmdHandler[cmd]
if present {
- func_ptr(tokens, remainStr)
+ func_ptr(tokens, remainStr,client)
} else {
fmt.Printf("Error: unknown Cmd: %v\n", cmd)
}
}
-func handleCmdTest(tokens []string, remainStr string) {
+func handleCmdTest(tokens []string, remainStr string, client * bufio.ReadWriter) {
//cmd:=tokens[0]
fmt.Printf("Test: %v\n", remainStr)
}