Skip to content

Commit a878885

Browse files
joegenJoegen Baclor
authored and
Joegen Baclor
committed
Preliminary test code for resip_ua module
1 parent 9494b6e commit a878885

18 files changed

+1453
-19
lines changed

include/OSS/.DS_Store

0 Bytes
Binary file not shown.

include/OSS/JS/JS.h

+1
Original file line numberDiff line numberDiff line change
@@ -217,6 +217,7 @@ inline JSStringHandle JSString(const char* str, std::size_t len) { return v8::St
217217
#define js_method_arg_declare_string(Var, Index) js_method_arg_type(std::string, Var, Index, js_assign_string, "Invalid Type. Expecting String")
218218
#define js_method_arg_declare_array(Var, Index) js_method_arg_type(JSArrayHandle, Var, Index, js_assign_array, "Invalid Type. Expecting Array")
219219
#define js_method_arg_declare_object(Var, Index) js_method_arg_type(JSObjectHandle, Var, Index, js_assign_object, "Invalid Type. Expecting Object")
220+
#define js_method_arg_declare_unwrapped_object(CLASS, VAR, INDEX) js_method_arg_declare_object(_##VAR##__temp, INDEX); CLASS* VAR = js_unwrap_object(CLASS, _##VAR##__temp->ToObject())
220221
#define js_method_arg_declare_external_object(Class, Var, Index) js_method_arg_type(Class*, Var, Index, js_assign_external_object<Class>, "Invalid Type. Expecting External Object")
221222
#define js_method_arg_declare_function(Var, Index) js_method_arg_type(JSLocalFunctionHandle, Var, Index, js_assign_function, "Invalid Type. Expecting Function")
222223
#define js_method_arg_declare_persistent_function(Var, Index) js_method_arg_type(JSPersistentFunctionHandle, Var, Index, js_assign_persistent_function, "Invalid Type. Expecting Function")
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,86 @@
1+
// Library: OSS_CORE - Foundation API for SIP B2BUA
2+
// Copyright (c) OSS Software Solutions
3+
// Contributor: Joegen Baclor - mailto:[email protected]
4+
//
5+
// Permission is hereby granted, to any person or organization
6+
// obtaining a copy of the software and accompanying documentation covered by
7+
// this license (the "Software") to use, execute, and to prepare
8+
// derivative works of the Software, all subject to the
9+
// "GNU Lesser General Public License (LGPL)".
10+
//
11+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
14+
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
15+
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
16+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17+
// DEALINGS IN THE SOFTWARE.
18+
//
19+
20+
#ifndef OSS_RESIPCLIENTREGISTRATIONHANDLER_H_INCLUDED
21+
#define OSS_RESIPCLIENTREGISTRATIONHANDLER_H_INCLUDED
22+
23+
24+
#include <v8.h>
25+
#include <vector>
26+
#include "OSS/JS/JSPlugin.h"
27+
#include "OSS/JSON/Json.h"
28+
#include "OSS/JS/JSEventArgument.h"
29+
30+
#include <resip/dum/RegistrationHandler.hxx>
31+
#include <rutil/SharedPtr.hxx>
32+
33+
class ResipClientRegistrationHandler : public OSS::JS::JSObjectWrap
34+
{
35+
public:
36+
JS_CONSTRUCTOR_DECLARE();
37+
38+
/// Called when registraion succeeds or each time it is sucessfully
39+
/// refreshed (manual refreshes only).
40+
/// virtual void onSuccess(ClientRegistrationHandle, const SipMessage& response)=0;
41+
42+
/// Called when all of my bindings have been removed
43+
/// virtual void onRemoved(ClientRegistrationHandle, const SipMessage& response) = 0;
44+
JS_METHOD_DECLARE(handleOnRemoved);
45+
46+
/// call on Retry-After failure.
47+
/// return values: -1 = fail, 0 = retry immediately, N = retry in N seconds
48+
/// virtual int onRequestRetry(ClientRegistrationHandle, int retrySeconds, const SipMessage& response)=0;
49+
JS_METHOD_DECLARE(handleOnRequestRetry);
50+
51+
/// Called if registration fails, usage will be destroyed (unless a
52+
/// Registration retry interval is enabled in the Profile)
53+
/// virtual void onFailure(ClientRegistrationHandle, const SipMessage& response)=0;
54+
JS_METHOD_DECLARE(handleOnFailure);
55+
56+
/// Called when a TCP or TLS flow to the server has terminated. This can be caused by socket
57+
/// errors, or missing CRLF keep alives pong responses from the server.
58+
// Called only if clientOutbound is enabled on the UserProfile and the first hop server
59+
/// supports RFC5626 (outbound).
60+
/// Default implementation is to immediately re-Register in an attempt to form a new flow.
61+
/// virtual void onFlowTerminated(ClientRegistrationHandle);
62+
JS_METHOD_DECLARE(handleOnFlowTerminated);
63+
64+
/// Called before attempting to refresh a registration
65+
/// Return true if the refresh should go ahead or false otherwise
66+
/// Default implementation always returns true
67+
/// virtual bool onRefreshRequired(ClientRegistrationHandle, const SipMessage& lastRequest);
68+
JS_METHOD_DECLARE(handleOnRefreshRequired);
69+
70+
resip::ClientRegistrationHandler* handler();
71+
private:
72+
ResipClientRegistrationHandler();
73+
virtual ~ResipClientRegistrationHandler();
74+
resip::ClientRegistrationHandler* _handler;
75+
};
76+
77+
//
78+
// Inlines
79+
//
80+
81+
inline resip::ClientRegistrationHandler* ResipClientRegistrationHandler::handler()
82+
{
83+
return _handler;
84+
}
85+
86+
#endif // OSS_RESIPCLIENTREGISTRATIONHANDLER_H_INCLUDED
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
1+
// Library: OSS_CORE - Foundation API for SIP B2BUA
2+
// Copyright (c) OSS Software Solutions
3+
// Contributor: Joegen Baclor - mailto:[email protected]
4+
//
5+
// Permission is hereby granted, to any person or organization
6+
// obtaining a copy of the software and accompanying documentation covered by
7+
// this license (the "Software") to use, execute, and to prepare
8+
// derivative works of the Software, all subject to the
9+
// "GNU Lesser General Public License (LGPL)".
10+
//
11+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
14+
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
15+
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
16+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17+
// DEALINGS IN THE SOFTWARE.
18+
//
19+
20+
#ifndef OSS_RESIPCLIENTSUBSCRIPTIONHANDLER_H_INCLUDED
21+
#define OSS_RESIPCLIENTSUBSCRIPTIONHANDLER_H_INCLUDED
22+
23+
24+
#include <v8.h>
25+
#include <vector>
26+
#include "OSS/JS/JSPlugin.h"
27+
#include "OSS/JSON/Json.h"
28+
#include "OSS/JS/JSEventArgument.h"
29+
30+
#include <resip/dum/SubscriptionHandler.hxx>
31+
#include <rutil/SharedPtr.hxx>
32+
33+
class ResipClientSubscriptionHandler : public OSS::JS::JSObjectWrap
34+
{
35+
public:
36+
struct update_data
37+
{
38+
std::string key;
39+
std::string eventBody;
40+
bool isOutOfOrder;
41+
};
42+
43+
JS_CONSTRUCTOR_DECLARE();
44+
45+
/// Client must call acceptUpdate or rejectUpdate for any onUpdateFoo
46+
/// virtual void onUpdatePending(ClientSubscriptionHandle, const SipMessage& notify, bool outOfOrder)=0;
47+
JS_METHOD_DECLARE(handleOnUpdatePending);
48+
49+
/// virtual void onUpdateActive(ClientSubscriptionHandle, const SipMessage& notify, bool outOfOrder)=0;
50+
JS_METHOD_DECLARE(handleOnUpdateActive);
51+
52+
/// unknown Subscription-State value
53+
/// virtual void onUpdateExtension(ClientSubscriptionHandle, const SipMessage& notify, bool outOfOrder)=0;
54+
JS_METHOD_DECLARE(handleOnUpdateExtension);
55+
56+
/// subscription can be ended through a notify or a failure response.
57+
/// virtual void onTerminated(ClientSubscriptionHandle, const SipMessage* msg)=0;
58+
JS_METHOD_DECLARE(handleOnTerminated);
59+
60+
/// not sure if this has any value - can be called for either a 200/SUBSCRIBE or a NOTIFY - whichever arrives first
61+
/// virtual void onNewSubscription(ClientSubscriptionHandle, const SipMessage& notify)=0;
62+
JS_METHOD_DECLARE(handleOnNewSubscription);
63+
64+
/// virtual void onNotifyNotReceived(ClientSubscriptionHandle);
65+
JS_METHOD_DECLARE(handleOnNotifyNotReceived);
66+
67+
/// Called when a TCP or TLS flow to the server has terminated. This can be caused by socket
68+
/// errors, or missing CRLF keep alives pong responses from the server.
69+
/// Called only if clientOutbound is enabled on the UserProfile and the first hop server
70+
/// supports RFC5626 (outbound).
71+
/// Default implementation is to re-form the subscription using a new flow
72+
/// virtual void onFlowTerminated(ClientSubscriptionHandle);
73+
JS_METHOD_DECLARE(handleOnFlowTerminated);
74+
75+
resip::ClientSubscriptionHandler* handler();
76+
77+
void onUpdatePending(const std::string& key, const std::string& eventBody, bool isOutOfOrder);
78+
void onUpdateActive(const std::string& key, const std::string& eventBody, bool isOutOfOrder);
79+
void onUpdateExtension(const std::string& key, const std::string& eventBody, bool isOutOfOrder);
80+
81+
protected:
82+
void onUpdatePendingIsolated(void* user_data);
83+
void onUpdateActiveIsolated(void* user_data);
84+
void onUpdateExtensionIsolated(void* user_data);
85+
86+
private:
87+
ResipClientSubscriptionHandler();
88+
virtual ~ResipClientSubscriptionHandler();
89+
resip::ClientSubscriptionHandler* _handler;
90+
JSPersistentFunctionHandle* _handleOnUpdatePending;
91+
JSPersistentFunctionHandle* _handleOnUpdateActive;
92+
JSPersistentFunctionHandle* _handleOnUpdateExtension;
93+
JSPersistentFunctionHandle* _handleOnTerminated;
94+
JSPersistentFunctionHandle* _handleOnNewSubscription;
95+
JSPersistentFunctionHandle* _handleOnNotifyNotReceived;
96+
JSPersistentFunctionHandle* _handleOnFlowTerminated;
97+
OSS::JS::JSIsolate::Ptr _isolate;
98+
};
99+
100+
//
101+
// Inlines
102+
//
103+
104+
inline resip::ClientSubscriptionHandler* ResipClientSubscriptionHandler::handler()
105+
{
106+
return _handler;
107+
}
108+
109+
#endif // OSS_RESIPCLIENTSUBSCRIPTIONHANDLER_H_INCLUDED
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
// Library: OSS_CORE - Foundation API for SIP B2BUA
2+
// Copyright (c) OSS Software Solutions
3+
// Contributor: Joegen Baclor - mailto:[email protected]
4+
//
5+
// Permission is hereby granted, to any person or organization
6+
// obtaining a copy of the software and accompanying documentation covered by
7+
// this license (the "Software") to use, execute, and to prepare
8+
// derivative works of the Software, all subject to the
9+
// "GNU Lesser General Public License (LGPL)".
10+
//
11+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
14+
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
15+
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
16+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17+
// DEALINGS IN THE SOFTWARE.
18+
//
19+
20+
#ifndef OSS_RESIPDIALOGUSAGEMANAGER_H_INCLUDED
21+
#define OSS_RESIPDIALOGUSAGEMANAGER_H_INCLUDED
22+
23+
24+
#include <v8.h>
25+
#include <vector>
26+
#include "OSS/JS/JSPlugin.h"
27+
#include "OSS/JSON/Json.h"
28+
#include "OSS/JS/JSEventArgument.h"
29+
30+
#include <resip/dum/SubscriptionHandler.hxx>
31+
#include <resip/dum/RegistrationHandler.hxx>
32+
#include <resip/dum/Handles.hxx>
33+
#include <resip/dum/DialogUsageManager.hxx>
34+
#include <resip/dum/DumThread.hxx>
35+
#include <rutil/SharedPtr.hxx>
36+
37+
class ResipDialogUsageManager : public OSS::JS::JSObjectWrap
38+
{
39+
public:
40+
JS_CONSTRUCTOR_DECLARE();
41+
JS_METHOD_DECLARE(setMasterProfile);
42+
JS_METHOD_DECLARE(addClientSubscriptionHandler);
43+
JS_METHOD_DECLARE(setClientRegistrationHandler);
44+
45+
resip::DialogUsageManager* dum();
46+
private:
47+
ResipDialogUsageManager();
48+
virtual ~ResipDialogUsageManager();
49+
resip::DialogUsageManager* _dum;
50+
};
51+
52+
//
53+
// Inlines
54+
//
55+
56+
inline resip::DialogUsageManager* ResipDialogUsageManager::dum()
57+
{
58+
return _dum;
59+
}
60+
#endif // OSS_RESIPDIALOGUSAGEMANAGER_H_INCLUDED
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
// Library: OSS_CORE - Foundation API for SIP B2BUA
2+
// Copyright (c) OSS Software Solutions
3+
// Contributor: Joegen Baclor - mailto:[email protected]
4+
//
5+
// Permission is hereby granted, to any person or organization
6+
// obtaining a copy of the software and accompanying documentation covered by
7+
// this license (the "Software") to use, execute, and to prepare
8+
// derivative works of the Software, all subject to the
9+
// "GNU Lesser General Public License (LGPL)".
10+
//
11+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
14+
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
15+
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
16+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17+
// DEALINGS IN THE SOFTWARE.
18+
//
19+
20+
#ifndef OSS_RESIPMASTERPROFILE_H_INCLUDED
21+
#define OSS_RESIPMASTERPROFILE_H_INCLUDED
22+
23+
24+
#include <v8.h>
25+
#include <vector>
26+
#include "OSS/JS/JSPlugin.h"
27+
#include "OSS/JSON/Json.h"
28+
#include "OSS/JS/JSEventArgument.h"
29+
30+
#include <resip/dum/MasterProfile.hxx>
31+
#include <rutil/SharedPtr.hxx>
32+
33+
class ResipMasterProfile : public OSS::JS::JSObjectWrap
34+
{
35+
public:
36+
JS_CONSTRUCTOR_DECLARE();
37+
JS_METHOD_DECLARE(addSupportedMethod);
38+
JS_METHOD_DECLARE(addAllowedEvent);
39+
JS_METHOD_DECLARE(validateAcceptEnabled);
40+
JS_METHOD_DECLARE(validateContentEnabled);
41+
JS_METHOD_DECLARE(setUserAgent);
42+
JS_METHOD_DECLARE(setOutboundProxy);
43+
JS_METHOD_DECLARE(setDefaultFrom);
44+
JS_METHOD_DECLARE(setDigestCredential);
45+
const resip::SharedPtr<resip::MasterProfile>& profile() const;
46+
private:
47+
ResipMasterProfile();
48+
virtual ~ResipMasterProfile();
49+
resip::SharedPtr<resip::MasterProfile> _profile;
50+
};
51+
52+
53+
//
54+
// Inlines
55+
//
56+
57+
inline const resip::SharedPtr<resip::MasterProfile>& ResipMasterProfile::profile() const
58+
{
59+
return _profile;
60+
}
61+
62+
#endif // OSS_RESIPMASTERPROFILE_H_INCLUDED
+57
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
1+
// Library: OSS_CORE - Foundation API for SIP B2BUA
2+
// Copyright (c) OSS Software Solutions
3+
// Contributor: Joegen Baclor - mailto:[email protected]
4+
//
5+
// Permission is hereby granted, to any person or organization
6+
// obtaining a copy of the software and accompanying documentation covered by
7+
// this license (the "Software") to use, execute, and to prepare
8+
// derivative works of the Software, all subject to the
9+
// "GNU Lesser General Public License (LGPL)".
10+
//
11+
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
12+
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
13+
// FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
14+
// SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
15+
// FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
16+
// ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
17+
// DEALINGS IN THE SOFTWARE.
18+
//
19+
20+
#ifndef OSS_RESIPSIPSTACK_H_INCLUDED
21+
#define OSS_RESIPSIPSTACK_H_INCLUDED
22+
23+
24+
#include <v8.h>
25+
#include <vector>
26+
#include "OSS/JS/JSPlugin.h"
27+
#include "OSS/JSON/Json.h"
28+
#include "OSS/JS/JSEventArgument.h"
29+
30+
#include <resip/stack/SipStack.hxx>
31+
#include <resip/stack/StackThread.hxx>
32+
#include <rutil/SharedPtr.hxx>
33+
34+
class ResipSIPStack : public OSS::JS::JSObjectWrap
35+
{
36+
public:
37+
JS_CONSTRUCTOR_DECLARE();
38+
JS_METHOD_DECLARE(run);
39+
JS_METHOD_DECLARE(shutdown);
40+
JS_METHOD_DECLARE(addTransport);
41+
resip::SipStack* stack();
42+
private:
43+
ResipSIPStack();
44+
virtual ~ResipSIPStack();
45+
resip::SipStack* _stack;
46+
};
47+
48+
//
49+
// Inlines
50+
//
51+
52+
inline resip::SipStack* ResipSIPStack::stack()
53+
{
54+
return _stack;
55+
}
56+
57+
#endif // OSS_RESIPSIPSTACK_H_INCLUDED

0 commit comments

Comments
 (0)