func TestSendCryptoMessage(t *testing.T) {
	d, err := setupDispatcher(t)
	if err != nil {
		t.Error("Unexpected error. ", err)
	}
	s := newServer(t)
	host := strings.Trim(s.URL, "ws://")
	clientID := uint32(1)
	conn, err := cryptochain.PrepareCurrentConn(host, clientID)
	if err != nil {
		t.Error("Expected nil. Got: ", err)
	}
	d.SendCryptoMessage(cryptoData, userHash2, conn)
}
Esempio n. 2
0
func (p *pool) GetActiveConnections() [][]byte {
	p.connections.Lock()
	defer p.connections.Unlock()
	var conns [][]byte
	for host, conn := range p.connections.c {
		if conn.sessionCreated {
			c, err := cryptochain.PrepareCurrentConn(host, conn.clientID)
			if err != nil {
				p.log.Error(err)
				continue
			}
			conns = append(conns, c)
		}
	}
	return conns
}