Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public class Person
- {
- public string Name { get; set; }
- public int Age { get; set; }
- }
- /// <summary>
- /// Example showing a new feature...
- /// You can access public getters/setters from javascript
- /// And you can now return stuff from actionmethods.
- /// The things you return will be sent back to the caller with the event of the method called.
- /// </summary>
- public class Example : XSocketController
- {
- /// <summary>
- /// Public getters/setters can be accessed...
- ///
- /// Set by calling: ws.trigger('set_Monkey',{value:'Sidney'});
- ///
- /// Get by binding: ws.bind('get_Monkey',function(d){console.log(d);});
- /// Trigger get: ws.trigger('get_Monkey',{});
- ///
- /// Note: For no access, set the [NoEvent] attr and public will not be exposed
- /// </summary>
- public string Monkey { get; set; }
- /// <summary>
- /// Until now you could only use void on ActionMethods in XSockets.
- /// Now we propose the following....
- /// If you return something we will send it back to the caller with the event being the name of the method called.
- /// You can ofcourse to send/sendtoall/sendto etc inside the methods as usual.
- ///
- /// Example:
- /// Calling: ws.trigger('stringtest',{})
- /// Would return a string "Zebras Are Nice" to...
- /// ws.bind('stringtest',function(d){console.log(d);});
- ///
- /// See other tested examples below.
- /// </summary>
- public string StringTest()
- {
- return "Zebras Are Nice";
- }
- public int IntTest()
- {
- return 77;
- }
- public Guid GuidTest()
- {
- return Guid.NewGuid();
- }
- public Person PersonTest()
- {
- return new Person { Name = "Uffe", Age = 36 };
- }
- public IList<Person> PersonListTest()
- {
- return new List<Person> { new Person { Name = "Uffe", Age = 36 }, new Person { Name = "Magnus", Age = 38 } };
- }
- //Just tested, not sure why we would have this :)
- public Func<Person> FuncTest()
- {
- return () => new Person { Name = "Uffe", Age = 36 };
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement