Skip to content

Commit

Permalink
added test server file to run wap server
Browse files Browse the repository at this point in the history
  • Loading branch information
ehsan6sha committed Dec 9, 2024
1 parent ca01c7c commit 720c280
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 3 deletions.
6 changes: 3 additions & 3 deletions wap/pkg/wifi/scan.go
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,9 @@ func parseLinux(output string) (wifis []Wifi, err error) {
return wifis[i].RSSI > wifis[j].RSSI
})

// Keep only the first 3 records
if len(wifis) > 3 {
wifis = wifis[:3]
// Keep only the first 6 records
if len(wifis) > 6 {
wifis = wifis[:6]
}

return wifis, nil
Expand Down
28 changes: 28 additions & 0 deletions wap/tests/server/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package main

import (
"fmt"
"os"
"os/signal"
"syscall"

"github.com/functionland/go-fula/wap/pkg/server"
)

func main() {
connectedCh := make(chan bool, 1)

mockPeerFn := func(clientPeerId string, bloxSeed string) (string, error) {
return "test-peer-id", nil
}

closer := server.Serve(mockPeerFn, "", "", connectedCh)
defer closer.Close()

sigChan := make(chan os.Signal, 1)
signal.Notify(sigChan, syscall.SIGINT, syscall.SIGTERM)

fmt.Println("Server is running. Press Ctrl+C to stop.")
<-sigChan
fmt.Println("\nShutting down server...")
}

0 comments on commit 720c280

Please sign in to comment.