The first onion.net Client API application "Hello User".
Open a new visual studio project and select the project type "console application". Thanks to .NET remoting, the onion.net Information Server does not have to be on the same computer in order to execute your application. Just activate a network protocol (e.g. tcp) in the configuration file of the server for this.
We now need some links in order to integrate the onion.net Client API. The following DLLs are found in the folder "onion.net Client API" of the onion.net installation directory:
- Onion.Client.dll
- Onion.Common.dll
- Onion.Server.dll
- Onion.License.dll
- log4net.dll
Add the links and write the following line code:
using System; using Onion.Client; class Program { static void Main(string[] args) { using (var session = new OnionSession("ipc://onion.net/onion/server", "admin", "admin")) { IUser user = session.Self; Console.WriteLine("Hello " + user.Name); } } }
This small program will open a connection (session) to the local onion.net server via the shared memory channel IPC with the access data of the user "admin". You can now get to all available units of the server via the session. The property "Self" gives information about the logged-in user. Thus the password can be changed, for example with the method “UpdatePassword”. The execution of this program should write the following output into the console: We shall now have a look at how we can read out data from the system.
Hello admin