func main() { lsplog.SetVerbose(3) lsplog.Vlogf(3, "[Request] Request has started") lsplog.Vlogf(3, "[Request] Args: %s", os.Args) port, _ := strconv.Atoi(os.Args[1]) srv, _ = lsp12.NewLspServer(port, &lsp12.LspParams{5, 2000}) clients = make(map[uint16]*client) workers = make(map[uint16]*worker) requestBuffer = abuf.NewBuf() workersAvailable = abuf.NewBuf() go networkHandler() //Scheduler for { workerConnId := workersAvailable.Remove().(uint16) req := requestBuffer.Remove().(*request) for clients[req.connId] == nil { req = requestBuffer.Remove().(*request) } freeWorker := workers[workerConnId] freeWorker.worksForClient = req.connId freeWorker.command = req.crackRequest srv.Write(workerConnId, []byte(req.crackRequest)) } }
func main() { wait := make(chan int, 1) p := &lsp12.LspParams{5, 2000} srv, e := lsp12.NewLspServer(6666, p) // fmt.Printf("%s %t\n", e, srv==nil) if e != nil { fmt.Printf("%s %t\n", e, srv == nil) } _, req, _ := srv.Read() fmt.Printf(string(req)) srv.Write(1, []byte("C 420df50a0a436cabe48e1597a9508a2b5449d35e 12300 12399")) time.Sleep(100 * time.Millisecond) // srv.Write(1, []byte("X")) _, res, _ := srv.Read() fmt.Printf(string(res)) <-wait }