Pygmalions.Prism.Remoting
1.1.2
dotnet add package Pygmalions.Prism.Remoting --version 1.1.2
NuGet\Install-Package Pygmalions.Prism.Remoting -Version 1.1.2
<PackageReference Include="Pygmalions.Prism.Remoting" Version="1.1.2" />
<PackageVersion Include="Pygmalions.Prism.Remoting" Version="1.1.2" />
<PackageReference Include="Pygmalions.Prism.Remoting" />
paket add Pygmalions.Prism.Remoting --version 1.1.2
#r "nuget: Pygmalions.Prism.Remoting, 1.1.2"
#:package Pygmalions.Prism.Remoting@1.1.2
#addin nuget:?package=Pygmalions.Prism.Remoting&version=1.1.2
#tool nuget:?package=Pygmalions.Prism.Remoting&version=1.1.2
Prism Remoting
This library contains a plugin to enable a proxy class to receive invocation data as a server, and a client generator to generate client proxies.
Concepts
Client
Remote client proxies are generated by RemoteClientGenerator (or its shared instance Remote).
Their methods which are marked with Remote attributes are override to encode the invocation data (arguments)
and send it to the Transporter and then wait and decode the return value.
The Transporter can be modified through IRemoteClient interface,
and this property will never be null since you have to specify a transporter before creating a remote client.
Server
Server proxy is generated by the Prism Generator. If a class have any method marked with Remote attribute,
then the RemotingPlugin will implement the IRemoteServer interface in its proxy class,
which enable it to handle invocation data through HandleInvocation method.
In HandleInvocation method, the meta data token of the method to invoke will be firstly decoded,
then, the invocation data will be decoded in the layout of the arguments of the chosen method.
The chosen method will be invoked after all parameters are decoded, then its return value will be encoded into bytes
and output from HandleInvocation method.
Transporter
This plugin does not want to force users to use a certain technique to transmission data,
so we provide a interface ITransporter.
To implement a transporter, you have to finish these functions:
- Object selection.
- Data transmission.
Detailed steps are as follows:
- Add object ID to the head or tail of the invocation data package.
- Transmit the data to the correct server application.
- (By handlers in server application) Find the correct server proxy according to the object ID.
- (By handlers in server application) Invoke the
HandleInvocationmethod. - (By handlers in server application) Add object ID to the head or tail of the return-value data package.
- (By handlers in client application) Find the correct transporter transaction.
- Return the return-value data package.
How to Use
- Mark
Remoteattribute on methods to allow them to be remotely invoked. - Implement
ITransporterinterface to provide data transmission ability.
Road Map
- Server generator.
- Client generator.
- Built-in coders for asic value type.
- Coder generator for arrays of basic value types.
- Coder generator for structure types which composed of basic value types → Support third-party serializers by 'CustomCoderAttribute'.
- Support async methods.
Suggestions About 'Data Coder'
Currently the built-in coders only support some built-in value types (integer, float, string, ...) and a few containers (array) or wrappers (Task and ValueTask), so we strongly recommend users use other serialization tools instead of the built-in ones. For example, protobuf-net is a good choice.
You can use it by implement ICoderProvider interface:
public class ProtobufProvider : ICoderProvider
{
public static void Encode<TData>(TData data, MemoryStream stream)
{
ProtoBuf.Serializer.Serialize(stream, data);
}
public static TData Decode<TData>(MemoryStream stream)
=> ProtoBuf.Serializer.Deserialize<TData>(stream);
public DataCoder GetEncoder(Type dataType)
{
return (code, stream) =>
{
code.Emit(OpCodes.Ldloc, stream);
code.Emit(OpCodes.Call,
typeof(ProtobufProvider).
GetMethod(nameof(Encode),
BindingFlags.Public | BindingFlags.Static)!
.MakeGenericMethod(dataType));
};
}
public DataCoder GetDecoder(Type dataType)
{
return (code, stream) =>
{
code.Emit(OpCodes.Ldloc, stream);
code.Emit(OpCodes.Call,
typeof(ProtobufProvider).
GetMethod(nameof(Decode),
BindingFlags.Public | BindingFlags.Static)!
.MakeGenericMethod(dataType));
};
}
}
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net6.0 is compatible. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. net8.0 was computed. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net6.0
- Pygmalions.Prism.Framework (>= 1.2.0)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.