.NET to Javascript compiler

Remoting API

"Remoting" group describes different development states and aspects of remoting interfaces implementation.
TestRemotingApp implements client part and a TestWebSite implements server site (an have to be started to run this samples). The download contains all needed projects.
Client uses "Proxy" and "Channel" objects to communicate with the server. The communication is asynchronous. On requests client specifies:
  • input parameters - data will be sent to server
  • success delegate - code will be called if request is succesfully completed. The success delegate recieves server output parameter and context parameters (see below)
  • failed delegate - code will be called if error occures. The failed delegate recieves exception and context parameters (see below)
For example:
The server provides the interface:
interface IServer
{
  string Execute(string input);
}

The Client proxy can be defined as such:
public abstract class ClientProxy
{
  public abstract IDisposable Execute(string input, Action<string> success, Action<Exception> failed);
  // or/and
  public abstract Task<string> Execute(string input);
}
No context parameters are used in the sample. JScriptSuite analyzes the method signatures and generates the proxy object which is based on ClientProxy and implements the abstract Execute methods.
In this sample ClientProxy declares two prototypes to execute "Execute" - server method.

Public properties and fields which have to be sent to/received from server, have to be marked with JScriptSuite.Remotimg.DataMemberAttribute (see sample).

Communication via Json and Soap is already supported. Developers can add any other protocol.

GenericProxy sample allows to communicate with the server without DTOs. Copying DTO to ViewModel Object is not needed.
public abstract class GenericProxy
{
    public abstract IDisposable GetPersons<TPersonsList, TPerson>(
        [DataMember(null, "Person")]
        IEnumerable<IPerson> persons,
        [DataMember(null, "Person")]
        Action<TPersonsList> success, Action<Exception> failed)
        where TPersonsList : IList<TPerson>, new()
        where TPerson : IPerson, new();
}
IPerson interface defines properties which will be sent to/recieved from server. Client can send/recieve ViewModel Objects directly.
CreateClient().GetPersons<ObservableList<Person>, Person>(request,
            delegate(ObservableList<Person> response)
            {
                ShowResult(response, null);
            },
            delegate(Exception e) { ShowResult(null, e); });
© 2009 JScriptSuite. All rights reserved.