From: Othmar Gsenger Date: Thu, 7 Mar 2013 22:11:18 +0000 (+0000) Subject: added cmdHandler X-Git-Url: https://git.realraum.at/?a=commitdiff_plain;h=432e02ae6007b8f85c3d7692dbe4ff7066d70a25;p=svn42.git added cmdHandler --- diff --git a/door_daemon_go/unix_socket_server.go b/door_daemon_go/unix_socket_server.go index a2e710a..eb34e0c 100644 --- a/door_daemon_go/unix_socket_server.go +++ b/door_daemon_go/unix_socket_server.go @@ -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 {