summaryrefslogtreecommitdiffstats
path: root/vendor/github.com/mrexodia/wray/transport.go
blob: 82f4d4d34f852d5b5f605e0c10ae23ee88e528cc (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
package wray

import (
	"errors"
)

type Transport interface {
	isUsable(string) bool
	connectionType() string
	send(map[string]interface{}) (Response, error)
	setUrl(string)
}

func SelectTransport(client *FayeClient, transportTypes []string, disabled []string) (Transport, error) {
	for _, transport := range registeredTransports {
		if contains(transport.connectionType(), transportTypes) && transport.isUsable(client.url) {
			return transport, nil
		}
	}
	return nil, errors.New("No usable transports available")
}