From 6fc12e97799255e977aa333f349ffdfeeb9719eb Mon Sep 17 00:00:00 2001 From: Mickael Remond Date: Sat, 8 Jun 2019 19:47:05 +0200 Subject: [PATCH] Fix import and test --- component.go | 24 +++++++++++------------- component_test.go | 5 +++-- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/component.go b/component.go index 4a42281..89a9afa 100644 --- a/component.go +++ b/component.go @@ -9,8 +9,6 @@ import ( "io" "net" "time" - - "gosrc.io/xmpp" ) const componentStreamOpen = "" @@ -140,11 +138,11 @@ func (c *Component) recv() (err error) { close(c.RecvChannel) c.streamError(p.Error.Local, p.Text) return errors.New("stream error: " + p.Error.Local) - case xmpp.IQ: + case IQ: switch inner := p.Payload[0].(type) { // Our component module handle disco info but can let component implementation // handle disco items queries - case *xmpp.DiscoInfo: + case *DiscoInfo: if p.Type == "get" { c.discoResult(p.PacketAttrs, inner) } @@ -223,25 +221,25 @@ func (handshakeDecoder) decode(p *xml.Decoder, se xml.StartElement) (Handshake, // Service discovery -func (c *Component) discoResult(attrs xmpp.PacketAttrs, info *xmpp.DiscoInfo) { - iq := xmpp.NewIQ("result", attrs.To, attrs.From, attrs.Id, "en") - var identity xmpp.Identity +func (c *Component) discoResult(attrs PacketAttrs, info *DiscoInfo) { + iq := NewIQ("result", attrs.To, attrs.From, attrs.Id, "en") + var identity Identity if info.Node == "" { - identity = xmpp.Identity{ + identity = Identity{ Name: c.Name, Category: c.Category, Type: c.Type, } } - payload := xmpp.DiscoInfo{ + payload := DiscoInfo{ Identity: identity, - Features: []xmpp.Feature{ - {Var: xmpp.NSDiscoInfo}, - {Var: xmpp.NSDiscoItems}, + Features: []Feature{ + {Var: NSDiscoInfo}, + {Var: NSDiscoItems}, }, } iq.AddPayload(&payload) - _ = c.xmpp.Send(iq) + _ = c.Send(iq) } diff --git a/component_test.go b/component_test.go index 690d962..20e3772 100644 --- a/component_test.go +++ b/component_test.go @@ -3,10 +3,11 @@ package xmpp // import "gosrc.io/xmpp" import "testing" func TestHandshake(t *testing.T) { - c := Component{ - Host: "test.localhost", + opts := ComponentOptions{ + Domain: "test.localhost", Secret: "mypass", } + c := Component{ComponentOptions: opts} streamID := "1263952298440005243" expected := "c77e2ef0109fbbc5161e83b51629cd1353495332"