示例#1
0
文件: server.go 项目: RobWC/enet
func main() {
	endpoint := "127.0.0.1:19091"
	c := install_signal()
	host, err := enet.NewHost(endpoint)
	panic_if_error(err)

	host.SetDataHandler(pong)
	host.SetConnectionHandler(on_peer_connected)
	host.SetDisconnectionHandler(on_peer_disconnected)
	host.Run(c)
}
示例#2
0
文件: client.go 项目: RobWC/enet
func main() {
	endpoint := "127.0.0.1:19091"
	c := install_signal()

	host, err := enet.NewHost("")
	panic_if_error(err)
	host.SetDataHandler(ping_on_reliable)
	host.SetConnectionHandler(ping_on_connect)
	host.SetDisconnectionHandler(func(enet.Host, string, int) {
		host.Stop()
	})
	host.Connect(endpoint)
	host.Run(c)
}