There are two interfaces: IConnection and IProxyClass. IConnection has a CallMethod method, which delegates the method call somewhere (for example to instance of class - calls it). IProxyClass has a Connection property of type IConnection. It has a function of calling the CallMethod method (for example when the method is called on it).
There are build-in implementations of these interfaces and you can create your own if you want. IConnection is implemented as ClassConnection witch delegates method calls to some object and StreamConnection which send method call parameters over to a stream and reads returned value. IProxyClass is implemented only as StreamProxy which reads calls from stream and writes result to it. However there is a class ProxyCreator which dynamically creates a class (using System.Reflection.Emit) implementing IProxyClass and interface specified in parameter. Every method required by the supplied interface is implemented like as this (really strange pseudo-C#)
public {returnType} {methodName}({parameter-n-type parameter-n}*)
{
	return this.Connection.CallMethod("{methodName}", new object[] { {parameter-n}* });
}

This is generated in IL (using ILGenerator).

Streaming

Stream classes are useful for connecting to other computer and calling methods on it. Currently is serializes arguments and sends them over the stream. On the other side it reads the arguments, calls the specified method, takes the result, serializes it and sends it. Currently it uses BinaryFormatter for serializing arguments and results, but I want to change this and use some my custom serializer, which will deserialize object as a proxy (with remote methods).

Last edited Aug 28, 2014 at 9:03 AM by exyi, version 2