diff --git a/Yavsc/Hubs/ChatHub.cs b/Yavsc/Hubs/ChatHub.cs index 9279e99b..9c98d3a8 100644 --- a/Yavsc/Hubs/ChatHub.cs +++ b/Yavsc/Hubs/ChatHub.cs @@ -58,6 +58,16 @@ namespace Yavsc Clients.All.addMessage("#"+name,message); } - + [Authorize] + public void PV (string userId, string message) + { + var sender = Context.User.Identity.Name; + // TODO personal black|white list + + // Contact list allowed only + + // only pro + var hubCxContext = Clients.User(userId); + var cli = Clients.Client(hubCxContext.ConnectionId); + cli.addPV(sender,message); + } } } diff --git a/Yavsc/Views/Home/Chat.cshtml b/Yavsc/Views/Home/Chat.cshtml index 98ba6e54..397f684b 100644 --- a/Yavsc/Views/Home/Chat.cshtml +++ b/Yavsc/Views/Home/Chat.cshtml @@ -5,9 +5,18 @@
+ + + +
@section scripts { @@ -27,6 +36,11 @@ $('#discussion').append('
  • ' + htmlEncode(name) + ': ' + htmlEncode(message) + '
  • '); }; + chat.client.PV = function (name, message) { + // Add the pv to the page. + $('#private').append('
  • ' + htmlEncode(name) + + ': ' + htmlEncode(message) + '
  • '); + }; // Get the user name and store it to prepend to messages. $('#displayname').val(prompt('Enter your name:', '')); // Set initial focus to message input box. @@ -39,6 +53,12 @@ // Clear text box and reset focus for next comment. $('#message').val('').focus(); }); + $('#sendpv').click(function () { + // Call the Send method on the hub. + chat.server.sendPV($('#to').val(), $('#message').val()); + // Clear text box and reset focus for next comment. + $('#message').val('').focus(); + }); }); }); // This optional function html-encodes messages for display in the page.