Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Cleaned up the drawing pad sample.

  • Loading branch information...
commit acb6d090275aaa278f20c7b625de2ff4329a409c 1 parent 081cb74
@davidfowl davidfowl authored
View
9 samples/SignalR.Hosting.AspNet.Samples/Hubs/DrawingPad/DrawingPad.cs
@@ -31,16 +31,15 @@ public class Line
public void Join()
{
- Clients.Caller.id = Interlocked.Increment(ref _id);
- Clients.Caller.color = colors[_id % colors.Length];
+ Clients.Caller.color = colors[Interlocked.Increment(ref _id) % colors.Length];
}
// A user has drawed a line ...
- [HubMethodName("DrawALine")]
- public void DrawLine(Line data)
+ [HubMethodName("Draw")]
+ public void Draw(Line data)
{
// ... propagate it to all users
- Clients.Others.lineDrawed(data);
+ Clients.Others.draw(data);
}
}
}
View
16 samples/SignalR.Hosting.AspNet.Samples/Hubs/DrawingPad/index.htm
@@ -27,26 +27,24 @@
</div>
<script type="text/javascript">
$(function () {
-
- var signalR = $.connection;
- var id = -1;
+ var drawingPad = $.connection.DrawingPad;
// someone draw something
- signalR.DrawingPad.client.lineDrawed = function (value) {
+ drawingPad.client.draw = function (value) {
$("#pad").drawingpad("line", value);
};
- signalR.hub.start({ transport: activeTransport }, function () {
- signalR.DrawingPad.server.join().done(function () {
+ $.connection.hub.start({ transport: activeTransport }, function () {
+
+ drawingPad.server.join().done(function () {
$("#connecting").hide();
$("#connected").show();
- id = signalR.DrawingPad.state.id;
- color = signalR.DrawingPad.state.color;
+ color = drawingPad.state.color;
// Listen for drawing
$("#pad").drawingpad({ linecolor: color }).bind('line.drawingpad', function (event, args) {
- signalR.DrawingPad.server.DrawALine(args);
+ drawingPad.server.Draw(args);
});
});
});
View
6 samples/SignalR.Hosting.AspNet.Samples/Scripts/hubs.js
@@ -201,10 +201,10 @@
return signalR.DrawingPad.invoke.apply(signalR.DrawingPad, $.merge(["Join"], $.makeArray(arguments)));
},
- DrawALine: function (data) {
- /// <summary>Calls the DrawALine method on the server-side DrawingPad hub.&#10;Returns a jQuery.Deferred() promise.</summary>
+ Draw: function (data) {
+ /// <summary>Calls the Draw method on the server-side DrawingPad hub.&#10;Returns a jQuery.Deferred() promise.</summary>
/// <param name="data" type="Object">Server side type is SignalR.Hosting.AspNet.Samples.Hubs.DrawingPad.DrawingPad+Line</param>
- return signalR.DrawingPad.invoke.apply(signalR.DrawingPad, $.merge(["DrawALine"], $.makeArray(arguments)));
+ return signalR.DrawingPad.invoke.apply(signalR.DrawingPad, $.merge(["Draw"], $.makeArray(arguments)));
}
};
Please sign in to comment.
Something went wrong with that request. Please try again.