-
Notifications
You must be signed in to change notification settings - Fork 4
Communicating with a server
Solal Pirelli edited this page Sep 24, 2016
·
4 revisions
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" );
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" );