Esempio n. 1
0
func Init() {

	if c, err := sql.Open("postgres", "dbname=datagram sslmode=disable"); err == nil {
		pg = c
	} else {
		panic(err)
	}

	newEvents = data.NewEventStream()

	prepareEventStatements()
}
Esempio n. 2
0
func ReceiveDatagrams(hostAndPort string) *data.EventStream {

	var conn *net.UDPConn

	conn, err := createUDPListener(hostAndPort)

	if err != nil {
		panic("Could not create UDP listener")
	}

	fmt.Printf("Listener for UDP connections on %s\n", conn.LocalAddr().String())

	eventStream := data.NewEventStream()

	go rcv(conn, eventStream)

	return eventStream

}