-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathServices.cpp
More file actions
76 lines (67 loc) · 2.61 KB
/
Services.cpp
File metadata and controls
76 lines (67 loc) · 2.61 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
#include "ISXRI.h"
#include "ISXRIServices.h"
#define SERVICE(_name_,_callback_,_variable_) HISXSERVICE _variable_=0;
#include "Services.h"
#undef SERVICE
bool RIFooFunction(const char *Name, unsigned int Age,float Height)
{
printf("Foo: %s. Age %d. Height: %fcm",Name,Age,Height);
return true;
}
void __cdecl RIService(ISXInterface *pClient, unsigned int MSG, void *lpData)
{
switch(MSG)
{
case ISXSERVICE_CLIENTADDED:
// This message indicates that a new client has been added to the service
// pClient is 0, because this message is a system message from Inner Space
// lpData is an ISXInterface* that is the pointer to the new client
{
// use lpData as the actual type, not as void *. We can make a new
// variable to do this:
ISXInterface *pNewClient=(ISXInterface *)lpData;
printf("RIService client added: %X",pNewClient);
// You may use the client pointer (pNewClient here) as an ID to track client-specific
// information. Some services such as the memory service do this to automatically
// remove memory modifications made by an extension when that extension is unloaded.
}
break;
case ISXSERVICE_CLIENTREMOVED:
// This message indicates that a client has been removed from the service
// pClient is 0, because this message is a system message from Inner Space
// lpData is an ISXInterface* that is the pointer to the removed client
{
// use lpData as the actual type, not as void *. We can make a new
// variable to do this:
ISXInterface *pRemovedClient=(ISXInterface *)lpData;
printf("RIService client removed: %X",pRemovedClient);
}
break;
case RI_FOO:
// This is a custom service request defined in ISXRIServices.h
// pClient is a valid pointer to the client that sent this request
// lpData is a RIRequest_Foo* as sent by the client
{
RIRequest_Foo *pFoo=(RIRequest_Foo*)lpData;
/*
* As described in ISXRIServices.h, pFoo is simply a remote call
* to RIFooFunction, and has all of the parameters and the outgoing
* return value ready to go.
*/
pFoo->Success=RIFooFunction(pFoo->Name,pFoo->Age,pFoo->Height);
/*
* That's it! In many cases, the functionality provided by the service will
* be something that should be per-client to automatically handle cleanup.
* In such cases, it would be prudent to pass the pClient to the function call
* for proper handling.
*/
}
break;
}
}
/*
* How to broadcast an outgoing service message (called a notification):
RINotification_Bar Bar;
Bar.Text="Some text to pass as part of the notification";
pFoo->Success=pISInterface->ServiceBroadcast(pExtension,hRIService,RI_BAR,&Bar);
*/