~samwhited/xmpp

ref: c71a17569b03f07e0fc407f1da2094c1796cec90 xmpp/handler.go -rw-r--r-- 712 bytes
c71a1756Sam Whited ibr2: Add API stability disclaimer to docs 4 years ago
                                                                                
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
// Copyright 2016 Sam Whited.
// Use of this source code is governed by the BSD 2-clause license that can be
// found in the LICENSE file.

package xmpp

import (
	"encoding/xml"
)

// A Handler triggers events or responds to incoming elements in an XML stream.
type Handler interface {
	HandleXMPP(s *Session, start *xml.StartElement)
}

// The HandlerFunc type is an adapter to allow the use of ordinary functions as
// XMPP handlers. If f is a function with the appropriate signature,
// HandlerFunc(f) is a Handler that calls f.
type HandlerFunc func(s *Session, start *xml.StartElement)

// HandleXMPP calls f(s, start).
func (f HandlerFunc) HandleXMPP(s *Session, start *xml.StartElement) {
	f(s, start)
}