Exemple #1
0
// newClient returns a new client for a given network connection.
func newClient(conn net.Conn, network *Network) *client {
	var c *client

	recvFunc := func(msg *irc.Message) {
		runloop.CallLater(func() { c.recvFunc(msg) })
	}
	errorFunc := func(err os.Error) {
		runloop.CallLater(func() { c.errorFunc(err) })
	}

	c = &client{conn: irc.NewConn(conn, recvFunc, errorFunc), network: network}
	return c
}
Exemple #2
0
// newServer returns a new server for a given network connection.
func newServer(conn net.Conn, network *Network) *server {
	var s *server

	if conn == nil {
		return nil
	}

	recvFunc := func(msg *irc.Message) {
		runloop.CallLater(func() { s.recvFunc(msg) })
	}
	errorFunc := func(err os.Error) {
		runloop.CallLater(func() { s.errorFunc(err) })
	}

	s = &server{irc.NewConn(conn, recvFunc, errorFunc), network}
	s.conn.Send(&irc.Message{Command: "NICK", Params: []string{"bouncin"}})
	s.conn.Send(&irc.Message{Command: "USER", Params: []string{"bouncin", "0", "*", "Bouncin test"}})
	return s
}