Exemplo n.º 1
0
func NewSession(conn net.Conn) *IoSession {
	reader := bufio.NewReader(conn)
	writer := bufio.NewWriter(conn)

	session := &IoSession{
		Id:       int64(uniq.GetUniq()),
		Conn:     conn,
		In:       make(Message),
		Out:      make(Message),
		Quit:     make(chan bool),
		Ready:    make(chan string),
		reader:   reader,
		writer:   writer,
		closed:   false,
		mutx:     make(chan bool, 1),
		ClientIp: conn.RemoteAddr().String(),
		Attrs:    make(map[string]interface{}, 0),
	}
	return session
}
Exemplo n.º 2
0
func getUniqName() string {
	return fmt.Sprintf("%s%d", NAME_PREFIX, uniq.GetUniq())
}