My Project
JabberEventBinding.h
1 #pragma once
2 #include <string>
3 #include <bitset>
4 #include <set>
5 #include <map>
6 
7 namespace ParaEngine
8 {
9  using namespace std;
10 
15  JE_NONE,
16 
17  JE_OnPresence = 0,//We received a presence packet.
18  JE_OnError,
19  JE_OnRegistered,//After calling Register(), the registration succeeded or failed.
20  JE_OnRegisterInfo,//after calling Register, information about the user is required. Fill in the given IQ with the requested information.
21  JE_OnIQ,//We received an IQ packet.
26  JE_OnLoginRequired,//AutoLogin is false, and it's time to log in.
38 
48  JE_OnRosterBegin, // Fired when a roster result starts, before any OnRosterItem events fire.
49  JE_OnRosterItem, //event for new roster items. A roster may belong to multiple groups
50  JE_OnRosterEnd, //Fired when a roster result is completed being processed.
51  JE_OnRosterError,
60 
65  JE_OnStanzaMessageChat,
66  JE_OnStanzaMessageGroupChat,
67  JE_OnStanzaMessageHeadline,
68  JE_OnStanzaMessageNormal,
73 
78 
89 
96 
97  JE_LAST,
98  JE_UNKNOWN=0xffff,
99  };
100 
105  {
106  public:
109 
112  {
113  public:
114  CScriptCallBack(){};
115  CScriptCallBack(const char* callbackScript):m_sCallbackScript(callbackScript){}
116  string m_sCallbackScript;
117  };
118 
119  static void StaticInit();
120  //initialize the event mapping table, the old mappings are erased.
121  void InitEventMappingTable(bool bDisable=false);
122 
123  public:
124 
126  void EnableEvent(int eEvent);
127  void DisableEvent(int eEvent);
128 
129 
133  void MapEvent(int eSrcEvent, int eDestEvent);
137  void UnmapEvent(int eSrcEvent, int eDestEvent);
141  bool IsMapTo(int eSrcEvent, int eDestEvent)const;
142 
143  //create an event's script, if it already has a script, the old one will be replace by the new one
144  void MapEventToScript(int eEvent,const CScriptCallBack *script);
145 
146  //delete an event's script, if any
147  void UnmapEventToScript(int eEvent);
148 
150  void ClearAllScripts();
151 
152  //return the script of a given event, null if not exists
153  const CScriptCallBack * GetEventScript(int eEvent)const;
154 
155  //if an event has script,
156  bool HasEventScript(int eEvent) const;
157 
158  //two helper functions for translating between string and the event value.
159  static int StringToEventValue(const string &str);
160  static const string& EventValueToString(int value);
161 
162  protected:
163  bitset<JE_LAST> m_pEventEnable;
164  map<int,CScriptCallBack> m_pEventToScript;
165  set<int> m_pEventMappingTable[JE_LAST];
166  static map<string,int> StringToEventTable;
167  static map<int,string> EventToStringTable;
168  private:
169  static bool g_bStaticInited;
170  };
171 }
Authentication failed.
Definition: JabberEventBinding.h:25
msg = {jckey, from=string:jid, event=number:MessageEventType}
Definition: JabberEventBinding.h:72
msg = {jckey, from=string:jid}
Definition: JabberEventBinding.h:84
msg = {jckey, from=string:jid}
Definition: JabberEventBinding.h:80
different physics engine has different winding order.
Definition: EventBinding.h:32
JabberEvents
Jabber events that a JC client can bind to.
Definition: JabberEventBinding.h:14
msg={jckey, jid=string:jid}
Definition: JabberEventBinding.h:95
Jabber event that could be bound with NPL script.
Definition: JabberEventBinding.h:104
The connection is complete, and the user is authenticated.
Definition: JabberEventBinding.h:32
a structure for holding the script callback.
Definition: JabberEventBinding.h:111
msg = {jckey, from=string:jid}
Definition: JabberEventBinding.h:88
msg = {jckey, error=int:ResourceBindError}
Definition: JabberEventBinding.h:75
The connection is disconnected or auth failed.
Definition: JabberEventBinding.h:35
Definition: enum_maker.hpp:46
msg = {jckey, from=string:jid, state=number:ChatStateType}
Definition: JabberEventBinding.h:70
msg = {jckey, state=number, issuer=string, peer=string,protocol=string,mac=string,cipher=string,compression=string,from =string,to=string}
Definition: JabberEventBinding.h:37
roster arrived.
Definition: JabberEventBinding.h:47
msg={jckey, jid=string:jid}
Definition: JabberEventBinding.h:91
We received a message packet.
Definition: JabberEventBinding.h:64
a roster item&#39;s presence arrived.
Definition: JabberEventBinding.h:55
msg = {jckey, from=string:jid}
Definition: JabberEventBinding.h:86
The connection is connected, but no stream:stream has been sent, yet.
Definition: JabberEventBinding.h:29
the user itself&#39;s presence arrived.
Definition: JabberEventBinding.h:59
msg={jckey, jid=string:jid,msg=string}
Definition: JabberEventBinding.h:93
msg = {jckey, error=int:SessionCreateError}
Definition: JabberEventBinding.h:77
msg = {jckey, from=string:jid}
Definition: JabberEventBinding.h:82