You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.3 KiB
Go

package main
import (
"fmt"
"os"
"flag"
"log"
"strconv"
"FRMS/internal/pkg/reactor"
"FRMS/internal/pkg/logging"
)
type coordinator interface {
Start()
}
func NewCoordinator(ip string,port int,ch chan error) coordinator {
// allows interface checking as opposed to calling directly
return reactor.NewCoordinator(ip,port,ch)
}
func main() {
var ip string
var port int
flag.Usage = func() {
w := flag.CommandLine.Output()
fmt.Fprintf(w, "Usage: %s port \n",os.Args[0])
}
iptr := flag.String("i","192.168.100.2","ip address of server")
//iptr := flag.String("i","192.1.168.136","ip address of laptop")
flag.Parse()
if flag.NArg() != 1 {
flag.Usage()
os.Exit(1)
}
args := flag.Args()
if p, err := strconv.Atoi(args[0]);p < 1024 || p > 65535 {
flag.Usage()
log.Fatal("Port must be between [1023,65535]")
} else if err != nil {
log.Fatal(err)
}
ip = *iptr
port, err := strconv.Atoi(args[0])
if err != nil {
log.Fatal(err)
}
ch := make(chan error)
rlc := NewCoordinator(ip,port,ch) // host port
go rlc.Start()
logging.Debug(logging.DStart, "Reactor Started")
err = <-ch
if err != nil {
log.Fatal(err)
}
}