Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
biboumi
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
99
Issues
99
List
Boards
Labels
Service Desk
Milestones
Merge Requests
12
Merge Requests
12
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
louiz’
biboumi
Commits
f35db5ce
Commit
f35db5ce
authored
May 06, 2014
by
louiz’
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implement next_id() to
parent
18b27793
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
23 additions
and
1 deletion
+23
-1
src/test.cpp
src/test.cpp
+8
-0
src/xmpp/xmpp_component.cpp
src/xmpp/xmpp_component.cpp
+7
-0
src/xmpp/xmpp_component.hpp
src/xmpp/xmpp_component.hpp
+8
-1
No files found.
src/test.cpp
View file @
f35db5ce
...
...
@@ -2,6 +2,7 @@
* Just a very simple test suite, by hand, using assert()
*/
#include <xmpp/xmpp_component.hpp>
#include <xmpp/xmpp_parser.hpp>
#include <utils/encoding.hpp>
#include <logger/logger.hpp>
...
...
@@ -58,6 +59,13 @@ int main()
assert
(
utils
::
remove_invalid_xml_chars
(
in
)
==
in
);
assert
(
utils
::
remove_invalid_xml_chars
(
"
\a
couco\u0008u\uFFFEt\uFFFFe
\r\n
♥"
)
==
"coucoute
\r\n
♥"
);
/**
* Id generation
*/
assert
(
XmppComponent
::
next_id
()
==
"0"
);
assert
(
XmppComponent
::
next_id
()
==
"1"
);
assert
(
XmppComponent
::
next_id
()
==
"2"
);
/**
* Utils
*/
...
...
src/xmpp/xmpp_component.cpp
View file @
f35db5ce
...
...
@@ -29,6 +29,8 @@
#define STANZA_NS "urn:ietf:params:xml:ns:xmpp-stanzas"
#define STREAMS_NS "urn:ietf:params:xml:ns:xmpp-streams"
unsigned
long
XmppComponent
::
current_id
=
0
;
XmppComponent
::
XmppComponent
(
const
std
::
string
&
hostname
,
const
std
::
string
&
secret
)
:
ever_auth
(
false
),
last_auth
(
false
),
...
...
@@ -783,3 +785,8 @@ void XmppComponent::send_self_disco_info(const std::string& id, const std::strin
iq
.
close
();
this
->
send_stanza
(
iq
);
}
std
::
string
XmppComponent
::
next_id
()
{
return
std
::
to_string
(
XmppComponent
::
current_id
++
);
}
src/xmpp/xmpp_component.hpp
View file @
f35db5ce
...
...
@@ -20,10 +20,16 @@ class XmppComponent: public SocketHandler
public:
explicit
XmppComponent
(
const
std
::
string
&
hostname
,
const
std
::
string
&
secret
);
~
XmppComponent
();
void
on_connection_failed
(
const
std
::
string
&
reason
)
override
final
;
void
on_connected
()
override
final
;
void
on_connection_close
()
override
final
;
void
parse_in_buffer
(
const
size_t
size
)
override
final
;
/**
* Returns a unique id, to be used in the 'id' element of our iq stanzas.
*/
static
std
::
string
next_id
();
/**
* Send a "close" message to all our connected peers. That message
* depends on the protocol used (this may be a QUIT irc message, or a
...
...
@@ -195,6 +201,8 @@ private:
*/
std
::
unordered_map
<
std
::
string
,
std
::
unique_ptr
<
Bridge
>>
bridges
;
static
unsigned
long
current_id
;
XmppComponent
(
const
XmppComponent
&
)
=
delete
;
XmppComponent
(
XmppComponent
&&
)
=
delete
;
XmppComponent
&
operator
=
(
const
XmppComponent
&
)
=
delete
;
...
...
@@ -202,4 +210,3 @@ private:
};
#endif // XMPP_COMPONENT_INCLUDED
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment