Communicating with a server - SolalPirelli/ThriftSharp GitHub Wiki

The ThriftCommunication object

To communicate with a server, the first step is to declare how the communication will take place.

Thrift supports quite a lot of protocols (binary, compact, JSON, and so on) and transports (HTTP, socket, framed, ...).
For now Thrift# only supports the binary protocol over HTTP transport.

Create a ThriftCommunication object like so:

var comm = ThriftCommunication.Binary()
                              .OverHttp( "http://example.org:1234/thrift" );

Creating a service proxy

Simply call the ThriftProxy.Create<T> method with a ThriftCommunication object, like this:

// Service definition
[ThriftService( "DirectoryService" )]
public interface IDirectoryService
{
    [ThriftMethod( "contains" )]
    Task<bool> ContainsAsync( [ThriftParameter( 1, "name" )] string name );
}

// somewhere in a method
var comm = ThriftCommunication.Binary()
                              .OverHttp( "http://example.org:1234/thrift" );
var svc = ThriftProxy.Create<IDirectoryService>( comm );
// Example:
bool contains = await svc.ContainsAsync( "John" );
⚠️ **GitHub.com Fallback** ⚠️