Muccu Fast Track

To start using Muccu, You only have to copy the dll into the bin directory, and hookup the Muccu HttpModule in web.config. Thats it and you'r flying. Again:
  • Copy the dll
  • Add the HttpModule of type: Muccu.HttpModule
  • Add a reference to muccu.js in Your Html

Now you are hooked up with the server - on to writing the servercode:
By convention; Muccu is scanning the assemblies in bin (and App_cod), for classes inheriting from: Muccu.JavaScriptService. All methods ar converted to JavaScript services, and can be accessed from script. F.ex.:

public class MyService : JavaScriptService
{
    public string HelloWorld(string name)
    {
        return string.Format("Hi {0}", name);
    }
}


And the clientside JavaScript to invoke the method:
muccu.MyService.helloWorld('Jesper')
    .complete(function(resp){
        alert(resp.result)
    });
// Will alert: 'Hi Jesper'


If you don't like the c# naming of the methods, you can decorate the class and it's methods with the JavaScriptAttribute, and give them another clientside name - like this:

[JavaScript("theService")]
public class MyService : JavaScriptService
{
    [JavaScript("sayHello")]
    public string HelloWorld(string name)
    {
        return string.Format("Hi {0}", name);
    }
}


And suddenly the clientcode looks like this:
muccu.theService.sayHello('Jesper');


You can have all the service methods You want, but bare in mind to name the classes different.
Debugging: Tracing

Last edited Sep 26, 2012 at 12:08 PM by TheIMan, version 8