Exemplo n.º 1
0
func NewClient(name string, conn net.Conn, s *Server) *Client {
	client := &Client{
		name:     name,
		realName: "",
		server:   s,
		channels: channel.NewChannels(),
	}

	handler := connection.Log(name, clientHandler{client})
	client.conn = connection.NewConn(conn, handler)

	log.Println("client started")

	return client
}
Exemplo n.º 2
0
func NewServer(name, address, port string) *Server {
	in := make(chan string)
	quit := make(chan struct{})
	clients := NewClients()
	channels := channel.NewChannels()

	return &Server{
		address:  address,
		port:     port,
		name:     name,
		in:       in,
		quit:     quit,
		clients:  clients,
		channels: channels,
	}
}