How to fix the error and run functions in an asynchronous thread?
    
    
    D:\nim-2.0.2\lib\pure\asyncmacro.nim(160, 5) webServerMatcher (Async)
    D:\pojects\MelonPlayer\source_code_app\main.nim(166, 3) template/generic 
instantiation of `router` from here
    
C:\Users\user\.nimble\pkgs2\jester-0.6.0-4834f85e61ae39f6b6acfb74d3bbba62d8779b66\jester.nim(1352,
 35) template/generic instantiation of `async` from here
    D:\pojects\MelonPlayer\source_code_app\main.nim(222, 13) template/generic 
instantiation of `await` from here
    D:\nim-2.0.2\lib\pure\asyncmacro.nim(160, 5) Error: await expects 
Future[T], got void
           Tip: 46 messages have been suppressed, use --verbose to show them.
    nimble.nim(229)          buildFromDir
    
    
    Run

libs: nigui, jester

code:
    
    
    proc startServer() {.thread, nimcall.} =
      echo "server thread started!"
      router webServer:
        get "/send@command?":
          if @"command" != "" and @"command".len() != 0:
            var arguments = findTextInBrackets(@"command")
            var packet: seq[string]
            for (index, text) in arguments:
              let commandPart = @"command"[0..<index] # Получаем подстроку 
"command" до заданного индекса
              let parts = commandPart.split(
                  ".") # Разбиваем подстроку по символу '.'
     # Добавляем полученные части в список packet
              packet.add(parts)
            echo packet
            
            ...
            
            
            elif packet[0] == "send":
              case packet[1]
              of "error":
                await echoError()
                resp "Start the Error windows"
              else:
                resp "{:red:}" & @"command" & " not found!"
            else:
              resp "{:red:}" & @"command" & " not found!"
          else:
            resp @"command" & " not found!"
    
    
    
    
    proc echoError(error: string = "error", typeError: string = "") =
      var window = newWindow()
      var listButtons = @["OK", "Exit", "Copy Error"]
      var res: int
      
      if typeError == "warn":
        res = window.msgBox(message = "Error:\n\n" & $error,
            title = "Melon Player Error:", button1 = fmt"{listButtons[0]}")
      elif typeError == "error" or typeError == "fatal":
        res = window.msgBox("Error:\n\n" & $error, "Melon Player Error:",
            listButtons[0], listButtons[1], listButtons[2])
      
      if res == 1:
        quit()
      elif res == 2:
        var cb = clipboard_new(nil)
        if cb.clipboard_set_text(error):
          quit()
        else:
          echo "Copy error"
    
    
    Run

Reply via email to