This is a very naive example of an Apache Thrift server running inside a WPF app accessed using a Node based Javascript Client. But, it works fine for my purpose !
- Step 1: Install NuGet Package for the C# library
Install-Package ApacheThrift -Version 0.12.0
- Step 2: Generate the C# class using the Thrift
IDLfile (ServiceContract.thrift)thrift-0.12.0.exe --gen csharp ThriftService.thrift- Add the geenrated C# file called
MyThriftService.csto the WPF solution - Implement the
ThriftServiceHandlerand build the solution. - Run the server by doing
F5on the VS editor
- Use the same IDL file (
ServiceContract.thrift) to generate a node based JS file - Run this command (notice the
js:nodelanguage option) -thrift-0.12.0.exe --gen js:node ServiceContract.thrift - This will generate a Javascript file (under
gen-nodejsfolder) which we will use for our JS client. Copy the files in the same location as ofclient.jsfile npm install thriftand use in yourclient.jsfile- Run the client by typing
node client.json the command line from the folder path ofclient.js. - In our example, you should see the output on the console as well as a new Window getting created via the Thrift server running inside the WPF app.