~samwhited/xmpp

a5944e6cdf1046479ba93095cb4ffd8d1d90dcb6 — Sam Whited 5 years ago e171a2b
Remove IQ outline; it will be on Client
1 files changed, 0 insertions(+), 32 deletions(-)

M iq.go
M iq.go => iq.go +0 -32
@@ 5,7 5,6 @@
package xmpp

import (
	"context"
	"encoding/xml"
	"errors"
	"strings"


@@ 64,34 63,3 @@ func (t *iqType) UnmarshalXMLAttr(attr xml.Attr) error {
	}
	return nil
}

// TODO: Should this be variadic and accept many payloads or many to's?
func (c *Conn) sendIQ(ctx context.Context, to *jid.JID, t iqType, v interface{}) (*IQ, error) {
	panic("xmpp: sendIQ not yet implemented")
}

// Do sends an IQ request and blocks until an IQ response is received. If the
// provided context expires before a response is received, the function unblocks
// and an error is returned. An error is only returned on timeouts or connection
// errors, error resonses to the IQ are expected and returned as normal IQ
// responses (err will still be nil).
//
// If the IQ is not of type Get or Set, panic.
func (c *Conn) Do(ctx context.Context, iq IQ) (resp *IQ, err error) {
	if iq.Type != Get && iq.Type != Set {
		panic("xmpp: Attempted to send non-response IQ with invalid type.")
	}
	return c.sendIQ(ctx, nil, iq.Type, iq)
}

// Set marshals the provided data to XML and then sends it as the payload of a
// "set" IQ stanza. For more information, see the Do function.
func (c *Conn) Set(ctx context.Context, to *jid.JID, payload interface{}) (resp *IQ, err error) {
	return c.sendIQ(ctx, to, Set, payload)
}

// Get marshals the provided data to XML and then sends it as the payload of a
// "get" IQ stanza. For more information see the Do function.
func (c *Conn) Get(ctx context.Context, to *jid.JID, payload interface{}) (resp *IQ, err error) {
	return c.sendIQ(ctx, to, Get, payload)
}