Test Results

About us

 Server Lesson 5: Write your first RTC remote function
Total posts: 1
 Author Server Lesson 5: Write your first RTC remote function
Danijel Tkalcec [RTC]

02.06.2006 01:33:57
Registered user
This is the first server lesson for writing remote functions. You will learn in this lesson how to use rtcServerModule, rtcFunctionGroup and rtcFunction components to write functions which can be called remotely by RTC clients. You can find the complete source code and textual version of this lesson below.

Estimated time to complete: 3 minutes

Click HERE to start the visual lesson

Here is an example how you can write a server to serve remote functions to clients.

1. Open a new Project
2. from the RTC Server tab, put RtcHttpServer on your form:
3. for RtcHttpServer1, set ServerPort = 80
4. for your Form, define OnCreate event:

You will notice that this is the same thing we did for sending files and dynamic content out. If you want to have a server that does multiple things, not only preocess remote function calls, you can also start from pont (5) on any of other Server lessons, to add remote function capabilities.

5. from the RTC Server tab, put one RtcFunctionGroup on your form:

You will use one FunctionGroup for each Form or Module where you want to implement remote functions.

6. from the RTC Server tab, put one RtcServerModule on your form:
7. for RtcServerModule1, set Server = RtcHttpServer1
8. for RtcServerModule1, set FunctionGroup = RtcFunctionGroup1
9. for RtcServerModule1, set ModuleFileName = '/mytest'

ModuleFileName is case-sensitive, so remember exactly what you use here, you will have to use exactly the same ModuleFileName in your rtcClientModule component for the Client.

You will use one rtcFunction component for each function you want to implement.

10. from the RTC Server tab, put one RtcFunction on your form:
11. for RtcFunction1, set FunctionGroup = RtcFunctionGroup1
12. for RtcFunction1, set FunctionName = 'hello'
13. for RtcFunction1, define the OnExecute event:
 Result.asString := 'Hello, '+Param.asString['name'];

14. Compile and run the project.  
15. Continue with the next lesson to write a client and test the server.