added cmdHandler
authorOthmar Gsenger <otti@realraum.at>
Thu, 7 Mar 2013 22:11:18 +0000 (22:11 +0000)
committerOthmar Gsenger <otti@realraum.at>
Thu, 7 Mar 2013 22:11:18 +0000 (22:11 +0000)
door_daemon_go/unix_socket_server.go

index a2e710a..eb34e0c 100644 (file)
@@ -2,6 +2,7 @@ package main
 import "fmt"
 import "net"
 import "bufio"
+import "strings"
 
 func readLineSafe(rw *bufio.ReadWriter) (string, error) {
   wasPrefix:=false
@@ -47,11 +48,17 @@ func handleConnection(c net.Conn) () {
          if line == "" {
            continue
          }
-         fmt.Printf("Received: %v\n", string(line))
+         fmt.Printf("Received: %v\n", line)
+         tokens:=strings.Fields(line)
+         remainStr:=strings.Join(tokens[1:]," ")
+         handleCmd(tokens,remainStr)
     }
 }
 
-
+func handleCmd(tokens []string, remainStr string) {
+  cmd:=tokens[0]
+  fmt.Printf("Handling Cmd: %v\n", cmd)
+}
 func main() {
   ln, err := net.Listen("unix", "/tmp/test.sock")
   if err != nil {