summaryrefslogtreecommitdiffstats
path: root/matterbridge.go
diff options
context:
space:
mode:
authorWim <wim@42.be>2017-04-01 17:24:19 +0200
committerWim <wim@42.be>2017-04-01 17:24:19 +0200
commita16ad8bf3b39d99658f306d3c065680c606e4801 (patch)
tree370528dd84572928161f4eff988f738581394ac0 /matterbridge.go
parent1e0490bd36ec20a7de43587f43feb6ec63c02ddb (diff)
downloadmatterbridge-msglm-a16ad8bf3b39d99658f306d3c065680c606e4801.tar.gz
matterbridge-msglm-a16ad8bf3b39d99658f306d3c065680c606e4801.tar.bz2
matterbridge-msglm-a16ad8bf3b39d99658f306d3c065680c606e4801.zip
Reuse connection when using same bridge with another gateway. See #87
Diffstat (limited to 'matterbridge.go')
-rw-r--r--matterbridge.go32
1 files changed, 14 insertions, 18 deletions
diff --git a/matterbridge.go b/matterbridge.go
index db05a596..85313d4b 100644
--- a/matterbridge.go
+++ b/matterbridge.go
@@ -8,6 +8,7 @@ import (
"github.com/42wim/matterbridge/gateway/samechannel"
log "github.com/Sirupsen/logrus"
"github.com/google/gops/agent"
+ "strings"
)
var (
@@ -39,31 +40,26 @@ func main() {
log.SetLevel(log.DebugLevel)
}
log.Printf("Running version %s %s", version, githash)
- cfg := config.NewConfig(*flagConfig)
- for _, gw := range cfg.SameChannelGateway {
- if !gw.Enable {
- continue
- }
- log.Printf("Starting samechannel gateway %#v", gw.Name)
- g := samechannelgateway.New(cfg, &gw)
- err := g.Start()
- if err != nil {
- log.Fatalf("Starting gateway failed %#v", err)
- }
- log.Printf("Started samechannel gateway %#v", gw.Name)
+ if strings.Contains(version, "-dev") {
+ log.Println("WARNING: THIS IS A DEVELOPMENT VERSION. Things may break.")
}
+ cfg := config.NewConfig(*flagConfig)
- for _, gw := range cfg.Gateway {
+ g := gateway.New(cfg)
+ sgw := samechannelgateway.New(cfg)
+ gwconfigs := sgw.GetConfig()
+ for _, gw := range append(gwconfigs, cfg.Gateway...) {
if !gw.Enable {
continue
}
- log.Printf("Starting gateway %#v", gw.Name)
- g := gateway.New(cfg, &gw)
- err := g.Start()
+ err := g.AddConfig(&gw)
if err != nil {
- log.Fatalf("Starting gateway failed %#v", err)
+ log.Fatalf("Starting gateway failed: %s", err)
}
- log.Printf("Started gateway %#v", gw.Name)
+ }
+ err := g.Start()
+ if err != nil {
+ log.Fatalf("Starting gateway failed: %s", err)
}
log.Printf("Gateway(s) started succesfully. Now relaying messages")
select {}