From 3ccc2680b03233330951d564033b35958a22d210 Mon Sep 17 00:00:00 2001 From: Martin/Geno Date: Thu, 6 Jun 2019 20:08:10 +0200 Subject: [PATCH] Add typing support: XEP-0085: Chat State Notifications --- msg_chat_state.go | 43 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 msg_chat_state.go diff --git a/msg_chat_state.go b/msg_chat_state.go new file mode 100644 index 0000000..72fca52 --- /dev/null +++ b/msg_chat_state.go @@ -0,0 +1,43 @@ +package xmpp // import "gosrc.io/xmpp" + +import "encoding/xml" + +/* +Support for: +- XEP-0085 - Chat State Notifications: https://xmpp.org/extensions/xep-0085.html +*/ + +const NSMsgChatStateNotifications = "http://jabber.org/protocol/chatstates" + +type StateActive struct { + MsgExtension + XMLName xml.Name `xml:"http://jabber.org/protocol/chatstates active"` +} + +type StateComposing struct { + MsgExtension + XMLName xml.Name `xml:"http://jabber.org/protocol/chatstates composing"` +} + +type StateGone struct { + MsgExtension + XMLName xml.Name `xml:"http://jabber.org/protocol/chatstates gone"` +} + +type StateInactive struct { + MsgExtension + XMLName xml.Name `xml:"http://jabber.org/protocol/chatstates inactive"` +} + +type StatePaused struct { + MsgExtension + XMLName xml.Name `xml:"http://jabber.org/protocol/chatstates paused"` +} + +func init() { + TypeRegistry.MapExtension(PKTMessage, xml.Name{NSMsgChatStateNotifications, "active"}, StateActive{}) + TypeRegistry.MapExtension(PKTMessage, xml.Name{NSMsgChatStateNotifications, "composing"}, StateComposing{}) + TypeRegistry.MapExtension(PKTMessage, xml.Name{NSMsgChatStateNotifications, "gone"}, StateGone{}) + TypeRegistry.MapExtension(PKTMessage, xml.Name{NSMsgChatStateNotifications, "inactive"}, StateInactive{}) + TypeRegistry.MapExtension(PKTMessage, xml.Name{NSMsgChatStateNotifications, "paused"}, StatePaused{}) +}