1// Copyright 2013 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5// Package xmpp implements the XMPP IM protocol, as specified in RFC 6120 and
6// 6121.
7package xmpp
8
9import (
10	"encoding/binary"
11	"io"
12
13	"github.com/coyim/coyim/xmpp/data"
14)
15
16func (c *conn) getCookie() data.Cookie {
17	var buf [8]byte
18	if _, err := io.ReadFull(c.Rand(), buf[:]); err != nil {
19		panic("Failed to read random bytes: " + err.Error())
20	}
21	return data.Cookie(binary.LittleEndian.Uint64(buf[:]))
22}
23
24func (c *conn) cancelInflights() {
25	for cookie := range c.inflights {
26		c.Cancel(cookie)
27	}
28}
29