You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

43 lines
626 B

package net
import (
"errors"
)
type Transport interface {
Listen() error
Init(c string) error
}
type TransportID int
const (
HTTP TransportID = iota + 1
PubSub
)
func TransportIDFromString(i string) TransportID {
switch i {
case "PubSub" :
return PubSub
case "HTTP":
return HTTP
default:
return -1
}
}
func Init(t TransportID) (Transport, error) {
switch t {
case PubSub :
p := new(PubSubHandle)
p.Init("vocdoni_pubsub_testing")
return p, nil
case HTTP :
h := new(HttpHandle)
h.Init("8080/submit")
return h, nil
default:
return nil, errors.New("Bad transport type specification")
}
}