XEP-0047: In-band Bytestreams¶
- class slixmpp.plugins.xep_0047.XEP_0047(xmpp, config=None)[source]¶
XEP-0047: In-Band Bytestreams
Events registered by this plugin:
Plugin Parameters:
block_size(default:4096): default block size to negociatemax_block_size(default:8192): max block size to acceptauto_accept(default:False): if incoming streams should beaccepted automatically.
- async open_stream(jid, *, block_size=None, sid=None, use_messages=False, ifrom=None, **iqkwargs)[source]¶
Open an IBB stream with a peer JID.
Changed in version 1.8.0: This function is now a coroutine and must be awaited. All parameters except
jidare keyword-args only.- Parameters
jid (
JID) – The remote JID to initiate the stream with.block_size (
Optional[int]) – The block size to advertise.sid (
Optional[str]) – The IBB stream id (if not provided, will be auto-generated).use_messages (
bool) – If the stream should use message stanzas instead of iqs.
- Return type
- Returns
The opened byte stream with the remote JID
- Raises
IqError – When the remote entity denied the stream.
- class slixmpp.plugins.xep_0047.IBBytestream(xmpp, sid, block_size, jid, peer, use_messages=False)[source]¶
XEP-0047 Stream abstraction. Created by the ibb plugin automatically.
Provides send methods and triggers ibb_stream_data events.
- async gather(max_data=None, timeout=3600)[source]¶
Gather all data sent on a stream until it is closed, and return it.
New in version 1.8.0.
- Parameters
max_data (
Optional[int]) – Max number of bytes to receive. (received data may be over this limit depending on block_size)timeout (
int) – Timeout after which an error will be raised.
- Raises
IqTimeout – If the timeout is reached.
- Return type
bytes- Returns
All bytes accumulated in the stream.
- async send(data, timeout=None)[source]¶
Send a single block of data.
- Parameters
data (
bytes) – Data to send (will be truncated if above block size).- Return type
int- Returns
Number of bytes sent.
Internal API methods¶
The API here is used to manage streams and authorize. The default handlers work with the config parameters.
jid:
JIDreceiving the stream initiation.node: stream id
ifrom: who the stream is from.
args:
Iqof the stream request.returns:
Trueif the stream should be accepted,Falseotherwise.
Check if the stream should be accepted. Uses the information setup by preauthorize_sid (0047 version) by default.
jid:
JIDreceiving the stream initiation.node: stream id
ifrom: who the stream is from.
args:
Iqof the stream request.returns:
Trueif the stream should be accepted,Falseotherwise.
A fallback handler (run after authorized_sid (0047 version)) to check if a stream should be accepted. Uses the
auto_acceptparameter by default.jid:
JIDreceiving the stream initiation.node: stream id
ifrom: who the stream will be from.
args: Unused.
Register a stream id to be accepted automatically (called from other plugins such as XEP-0095).
- get_stream¶
jid:
JIDof local receiver.node: stream id
ifrom: who the stream is from.
args: unused
returns:
IBBytestream
Return a currently opened stream between two JIDs.
- set_stream¶
jid:
JIDof local receiver.node: stream id
ifrom: who the stream is from.
args: unused
Register an opened stream between two JIDs.
- del_stream¶
jid:
JIDof local receiver.node: stream id
ifrom: who the stream is from.
args: unused
Delete a stream between two JIDs.
Stanza elements¶
- class slixmpp.plugins.xep_0047.stanza.Close(xml=None, parent=None)[source]¶
- interfaces: ClassVar[Set[str]] = {'sid'}¶
The set of keys that the stanza provides for accessing and manipulating the underlying XML object. This set may be augmented with the
plugin_attribvalue of any registered stanza plugins.
- iterables: List[ElementBase]¶
A list of child stanzas whose class is included in
plugin_iterables.
- loaded_plugins: Set[str]¶
- name: ClassVar[str] = 'close'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBaseobject for<message />would usename = 'message'.
- namespace: str = 'http://jabber.org/protocol/ibb'¶
The XML namespace for the element. Given
<foo xmlns="bar" />, thennamespace = "bar"should be used. The default namespace isjabber:clientsince this is being used in an XMPP library.
- parent: Optional[ReferenceType[ElementBase]]¶
A
weakref.weakrefto the parent stanza, if there is one. If not, thenparentisNone.
- plugin_attrib: ClassVar[str] = 'ibb_close'¶
For
ElementBasesubclasses which are intended to be used as plugins, theplugin_attribvalue defines the plugin name. Plugins may be accessed by using theplugin_attribvalue as the interface. An example usingplugin_attrib = 'foo':register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- plugins: Dict[Tuple[str, Optional[str]], ElementBase]¶
An ordered dictionary of plugin stanzas, mapped by their
plugin_attribvalue.
- tag: str¶
The name of the tag for the stanza’s root element. It is the same as calling
tag_name()and is formatted as'{namespace}elementname'.
- xml: ET.Element¶
The underlying XML object for the stanza. It is a standard
xml.etree.ElementTreeobject.
- class slixmpp.plugins.xep_0047.stanza.Data(xml=None, parent=None)[source]¶
-
- interfaces: ClassVar[Set[str]] = {'data', 'seq', 'sid'}¶
The set of keys that the stanza provides for accessing and manipulating the underlying XML object. This set may be augmented with the
plugin_attribvalue of any registered stanza plugins.
- iterables: List[ElementBase]¶
A list of child stanzas whose class is included in
plugin_iterables.
- loaded_plugins: Set[str]¶
- name: ClassVar[str] = 'data'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBaseobject for<message />would usename = 'message'.
- namespace: str = 'http://jabber.org/protocol/ibb'¶
The XML namespace for the element. Given
<foo xmlns="bar" />, thennamespace = "bar"should be used. The default namespace isjabber:clientsince this is being used in an XMPP library.
- parent: Optional[ReferenceType[ElementBase]]¶
A
weakref.weakrefto the parent stanza, if there is one. If not, thenparentisNone.
- plugin_attrib: ClassVar[str] = 'ibb_data'¶
For
ElementBasesubclasses which are intended to be used as plugins, theplugin_attribvalue defines the plugin name. Plugins may be accessed by using theplugin_attribvalue as the interface. An example usingplugin_attrib = 'foo':register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- plugins: Dict[Tuple[str, Optional[str]], ElementBase]¶
An ordered dictionary of plugin stanzas, mapped by their
plugin_attribvalue.
- sub_interfaces: ClassVar[Set[str]] = {'data'}¶
A subset of
interfaceswhich maps interfaces to direct subelements of the underlying XML object. Using this set, the text of these subelements may be set, retrieved, or removed without needing to define custom methods.
- tag: str¶
The name of the tag for the stanza’s root element. It is the same as calling
tag_name()and is formatted as'{namespace}elementname'.
- xml: ET.Element¶
The underlying XML object for the stanza. It is a standard
xml.etree.ElementTreeobject.
- class slixmpp.plugins.xep_0047.stanza.Open(xml=None, parent=None)[source]¶
-
- interfaces: ClassVar[Set[str]] = {'block_size', 'sid', 'stanza'}¶
The set of keys that the stanza provides for accessing and manipulating the underlying XML object. This set may be augmented with the
plugin_attribvalue of any registered stanza plugins.
- iterables: List[ElementBase]¶
A list of child stanzas whose class is included in
plugin_iterables.
- loaded_plugins: Set[str]¶
- name: ClassVar[str] = 'open'¶
The XML tag name of the element, not including any namespace prefixes. For example, an
ElementBaseobject for<message />would usename = 'message'.
- namespace: str = 'http://jabber.org/protocol/ibb'¶
The XML namespace for the element. Given
<foo xmlns="bar" />, thennamespace = "bar"should be used. The default namespace isjabber:clientsince this is being used in an XMPP library.
- parent: Optional[ReferenceType[ElementBase]]¶
A
weakref.weakrefto the parent stanza, if there is one. If not, thenparentisNone.
- plugin_attrib: ClassVar[str] = 'ibb_open'¶
For
ElementBasesubclasses which are intended to be used as plugins, theplugin_attribvalue defines the plugin name. Plugins may be accessed by using theplugin_attribvalue as the interface. An example usingplugin_attrib = 'foo':register_stanza_plugin(Message, FooPlugin) msg = Message() msg['foo']['an_interface_from_the_foo_plugin']
- plugins: Dict[Tuple[str, Optional[str]], ElementBase]¶
An ordered dictionary of plugin stanzas, mapped by their
plugin_attribvalue.
- tag: str¶
The name of the tag for the stanza’s root element. It is the same as calling
tag_name()and is formatted as'{namespace}elementname'.
- xml: ET.Element¶
The underlying XML object for the stanza. It is a standard
xml.etree.ElementTreeobject.