Exemple #1
0
func main() {

	chatServer = chat.CreateChatServer()

	go createSocketServer(9981)

	createWebsocketServer(6636)
}
Exemple #2
0
func run(port int) {

	var address = fmt.Sprintf(":%d", port)
	var listener, err = net.Listen("tcp", address)
	if err != nil {
		log.Fatalf("Listen error: %s\n", err.Error())
	}

	log.Printf("Listening ...\n")

	var chat_server = chat.CreateChatServer()

	for {
		var conn, err = listener.Accept()
		if err != nil {
			log.Printf("Accept new connection error: %s\n", err.Error())
		} else {
			chat_server.OnNewConnection(conn)
		}
	}
}