package main

import (
	"os"
	"os/signal"
	"syscall"
)

var MulticastEntity AbstractMulticast
var BstChannel = make(chan string, 1)
var ZoreideBridge AbstractBridge

const numberlenght = 18

func main() {

	MulticastEntity.GetMulticastReady()
	go MulticastEntity.WriteNumberToMulticast(ZoreideBridge)
	go MulticastEntity.ReadNumberFromMulticast()
	go ZoreideBridge.WaitAndClean(MulticastEntity)
	go ZoreideBridge.HierarchyReLocator(MulticastEntity)

	// Just a nice way to wait until the Operating system sends a kill signal.
	// select{} was just horrible.
	c := make(chan os.Signal, 1)
	signal.Notify(c, os.Interrupt, syscall.SIGTERM)
	<-c
	ZoreideBridge.removeIPandBridgeInt()
	os.Exit(0)

}
