本文整理汇总了C#中JabbR.ViewModels.UserViewModel类的典型用法代码示例。如果您正苦于以下问题:C# UserViewModel类的具体用法?C# UserViewModel怎么用?C# UserViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserViewModel类属于JabbR.ViewModels命名空间,在下文中一共展示了UserViewModel类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C#代码示例。
示例1: MessageViewModel
public MessageViewModel(ChatMessage message)
{
Id = message.Id;
Content = message.Content;
User = new UserViewModel(message.User);
When = message.When;
}
开发者ID:shimazoe,项目名称:cchat2,代码行数:7,代码来源:MessageViewModel.cs
示例2: MessageViewModel
public MessageViewModel(ChatMessage message)
{
Id = message.Id;
Content = message.Content;
HtmlContent = message.HtmlContent;
User = new UserViewModel(message.User);
When = message.When;
HtmlEncoded = message.HtmlEncoded;
MessageType = message.MessageType;
Source = message.Source;
ImageUrl = message.ImageUrl;
}
开发者ID:phillip-haydon,项目名称:JabbR,代码行数:12,代码来源:MessageViewModel.cs
示例3: MessageViewModel
public MessageViewModel(ChatMessage message)
{
Id = message.Id;
Content = message.Content;
HtmlContent = message.HtmlContent;
User = new UserViewModel(message.User);
UserRoomPresence = ChatService.GetUserRoomPresence(message.User, message.Room);
When = message.When;
HtmlEncoded = message.HtmlEncoded;
MessageType = message.MessageType;
Source = message.Source;
ImageUrl = message.ImageUrl;
}
开发者ID:BrianRosamilia,项目名称:JabbR,代码行数:13,代码来源:MessageViewModel.cs
示例4: OnUserNameChanged
public void OnUserNameChanged(ChatUser user, string oldUserName, string newUserName)
{
// Create the view model
var userViewModel = new UserViewModel(user);
// Tell the user's connected clients that the name changed
foreach (var client in user.ConnectedClients)
{
HubContext.Clients.Client(client.Id).userNameChanged(userViewModel);
}
// Notify all users in the rooms
foreach (var room in user.Rooms)
{
HubContext.Clients.Group(room.Name).changeUserName(oldUserName, userViewModel, room.Name);
}
}
开发者ID:jharjadi,项目名称:JabbR,代码行数:17,代码来源:ChatNotificationService.cs
示例5: LogOn
private void LogOn(ChatUser user, string clientId)
{
// Update the client state
Caller.id = user.Id;
Caller.name = user.Name;
Caller.hash = user.Hash;
var userViewModel = new UserViewModel(user);
var rooms = new List<RoomViewModel>();
var ownedRooms = user.OwnedRooms.Select(r => r.Key);
foreach (var room in user.Rooms)
{
var isOwner = ownedRooms.Contains(room.Key);
// Tell the people in this room that you've joined
Clients[room.Name].addUser(userViewModel, room.Name, isOwner).Wait();
// Add the caller to the group so they receive messages
Groups.Add(clientId, room.Name).Wait();
// Add to the list of room names
rooms.Add(new RoomViewModel
{
Name = room.Name,
Private = room.Private,
Closed = room.Closed
});
}
// Initialize the chat with the rooms the user is in
Caller.logOn(rooms);
}
开发者ID:NTaylorMullen,项目名称:JabbR,代码行数:34,代码来源:Chat.cs
示例6: DisconnectClient
private void DisconnectClient(string clientId)
{
_service.DisconnectClient(clientId);
// Sleep a little so that a browser refresh doesn't show the user
// coming offline and back online
Thread.Sleep(500);
// Query for the user to get the updated status
ChatUser user = _repository.GetUserByClientId(clientId);
// There's no associated user for this client id
if (user == null)
{
return;
}
// The user will be marked as offline if all clients leave
if (user.Status == (int)UserStatus.Offline)
{
foreach (var room in user.Rooms)
{
var userViewModel = new UserViewModel(user);
Clients[room.Name].leave(userViewModel, room.Name).Wait();
}
}
}
开发者ID:NTaylorMullen,项目名称:JabbR,代码行数:28,代码来源:Chat.cs
示例7: Reconnect
public Task Reconnect(IEnumerable<string> groups)
{
string id = GetUserId();
if (String.IsNullOrEmpty(id))
{
return null;
}
ChatUser user = _repository.VerifyUserId(id);
// Make sure this client is being tracked
_service.AddClient(user, Context.ConnectionId, UserAgent);
var currentStatus = (UserStatus)user.Status;
if (currentStatus == UserStatus.Offline)
{
// Mark the user as inactive
user.Status = (int)UserStatus.Inactive;
_repository.CommitChanges();
// If the user was offline that means they are not in the user list so we need to tell
// everyone the user is really in the room
var userViewModel = new UserViewModel(user);
foreach (var room in user.Rooms)
{
var isOwner = user.OwnedRooms.Contains(room);
// Tell the people in this room that you've joined
Clients[room.Name].addUser(userViewModel, room.Name, isOwner).Wait();
// Add the caller to the group so they receive messages
Groups.Add(Context.ConnectionId, room.Name).Wait();
}
}
return null;
}
开发者ID:NTaylorMullen,项目名称:JabbR,代码行数:40,代码来源:Chat.cs
示例8: foreach
void INotificationService.RemoveAdmin(ChatUser targetUser)
{
foreach (var client in targetUser.ConnectedClients)
{
// Tell this client it's no longer an owner
Clients[client.Id].demoteAdmin();
}
var userViewModel = new UserViewModel(targetUser);
// Tell all users in rooms to change the admin status
foreach (var room in targetUser.Rooms)
{
Clients[room.Name].removeAdmin(userViewModel, room.Name);
}
// Tell the calling client the removal of admin status was successful
Caller.adminRemoved(targetUser.Name);
}
开发者ID:NTaylorMullen,项目名称:JabbR,代码行数:19,代码来源:Chat.cs
示例9: UserViewModel
void INotificationService.LockRoom(ChatUser targetUser, ChatRoom room)
{
var userViewModel = new UserViewModel(targetUser);
// Tell the room it's locked
Clients.lockRoom(userViewModel, room.Name);
// Tell the caller the room was successfully locked
Caller.roomLocked(room.Name);
// Notify people of the change
OnRoomChanged(room);
}
开发者ID:NTaylorMullen,项目名称:JabbR,代码行数:13,代码来源:Chat.cs
示例10: UserViewModel
void INotificationService.JoinRoom(ChatUser user, ChatRoom room)
{
var userViewModel = new UserViewModel(user);
var roomViewModel = new RoomViewModel
{
Name = room.Name,
Private = room.Private,
Welcome = room.Welcome ?? "",
Closed = room.Closed
};
var isOwner = user.OwnedRooms.Contains(room);
// Tell all clients to join this room
foreach (var client in user.ConnectedClients)
{
Clients.Client(client.Id).joinRoom(roomViewModel);
}
// Tell the people in this room that you've joined
Clients.Group(room.Name).addUser(userViewModel, room.Name, isOwner).Wait();
// Notify users of the room count change
OnRoomChanged(room);
foreach (var client in user.ConnectedClients)
{
Groups.Add(client.Id, room.Name);
}
}
开发者ID:codeprogression,项目名称:JabbR,代码行数:30,代码来源:Chat.cs
示例11: SetTypingIndicatorOff
private void SetTypingIndicatorOff(ChatUser user)
{
var userViewModel = new UserViewModel(user);
// Set the typing indicator off in all rooms
foreach (var r in user.Rooms)
{
Clients[r.Name].setTyping(userViewModel, r.Name, false);
}
}
开发者ID:redsquare,项目名称:JabbR,代码行数:10,代码来源:Chat.cs
示例12: LogOn
private void LogOn(ChatUser user, string clientId)
{
// Update the client state
Caller.id = user.Id;
Caller.name = user.Name;
var userViewModel = new UserViewModel(user);
var rooms = new List<RoomViewModel>();
foreach (var room in user.Rooms)
{
var isOwner = user.OwnedRooms.Contains(room);
// Tell the people in this room that you've joined
Clients[room.Name].addUser(userViewModel, room.Name, isOwner).Wait();
// Update the room count
OnRoomChanged(room);
// Update activity
UpdateActivity(user, room);
// Add the caller to the group so they receive messages
GroupManager.AddToGroup(clientId, room.Name).Wait();
// Add to the list of room names
rooms.Add(new RoomViewModel
{
Name = room.Name,
Private = room.Private
});
}
// Initialize the chat with the rooms the user is in
Caller.logOn(rooms);
}
开发者ID:redsquare,项目名称:JabbR,代码行数:36,代码来源:Chat.cs
示例13: DisconnectClient
private void DisconnectClient(string clientId)
{
ChatUser user = _service.DisconnectClient(clientId);
// There's no associated user for this client id
if (user == null)
{
return;
}
// Turn the typing indicator off for this user (even if it's just one client)
SetTypingIndicatorOff(user);
// The user will be marked as offline if all clients leave
if (user.Status == (int)UserStatus.Offline)
{
foreach (var room in user.Rooms)
{
var userViewModel = new UserViewModel(user);
Clients[room.Name].leave(userViewModel, room.Name).Wait();
OnRoomChanged(room);
}
}
}
开发者ID:redsquare,项目名称:JabbR,代码行数:26,代码来源:Chat.cs
示例14: Typing
public void Typing(bool isTyping)
{
if (OutOfSync)
{
return;
}
string id = Caller.id;
string roomName = Caller.activeRoom;
if (String.IsNullOrEmpty(id))
{
return;
}
ChatUser user = _repository.GetUserById(id);
if (user == null)
{
return;
}
ChatRoom room = _repository.VerifyUserRoom(user, roomName);
if (isTyping)
{
UpdateActivity(user, room);
var userViewModel = new UserViewModel(user);
Clients[room.Name].setTyping(userViewModel, room.Name, true);
}
else
{
SetTypingIndicatorOff(user);
}
}
开发者ID:redsquare,项目名称:JabbR,代码行数:35,代码来源:Chat.cs
示例15: GetUserId
void INotificationService.ListRooms(ChatUser user)
{
string userId = GetUserId();
var userModel = new UserViewModel(user);
Caller.showUsersRoomList(userModel, user.Rooms.Allowed(userId).Select(r => r.Name));
}
开发者ID:NTaylorMullen,项目名称:JabbR,代码行数:7,代码来源:Chat.cs
示例16: OnReconnected
public override Task OnReconnected()
{
var userId = Context.User.Identity.Name;
ChatUser user = _repository.VerifyUserId(userId);
// Make sure this client is being tracked
_service.AddClient(user, Context.ConnectionId, UserAgent);
var currentStatus = (UserStatus)user.Status;
if (currentStatus == UserStatus.Offline)
{
// Mark the user as inactive
user.Status = (int)UserStatus.Inactive;
_repository.CommitChanges();
// If the user was offline that means they are not in the user list so we need to tell
// everyone the user is really in the room
var userViewModel = new UserViewModel(user);
foreach (var room in user.Rooms)
{
var isOwner = user.OwnedRooms.Contains(room);
// Tell the people in this room that you've joined
Clients.Group(room.Name).addUser(userViewModel, room.Name, isOwner).Wait();
// Add the caller to the group so they receive messages
Groups.Add(Context.ConnectionId, room.Name);
}
}
return base.OnReconnected();
}
开发者ID:codeprogression,项目名称:JabbR,代码行数:35,代码来源:Chat.cs
示例17: Typing
public void Typing(string roomName)
{
string userId = Context.User.Identity.Name;
ChatUser user = _repository.GetUserById(userId);
ChatRoom room = _repository.VerifyUserRoom(_cache, user, roomName);
UpdateActivity(user, room);
var userViewModel = new UserViewModel(user);
Clients.Group(room.Name).setTyping(userViewModel, room.Name);
}
开发者ID:codeprogression,项目名称:JabbR,代码行数:13,代码来源:Chat.cs
示例18: DisconnectClient
private void DisconnectClient(string clientId)
{
string userId = _service.DisconnectClient(clientId);
if (String.IsNullOrEmpty(userId))
{
return;
}
// Query for the user to get the updated status
ChatUser user = _repository.GetUserById(userId);
// There's no associated user for this client id
if (user == null)
{
return;
}
// The user will be marked as offline if all clients leave
if (user.Status == (int)UserStatus.Offline)
{
foreach (var room in user.Rooms)
{
var userViewModel = new UserViewModel(user);
Clients.OthersInGroup(room.Name).leave(userViewModel, room.Name);
}
}
}
开发者ID:codeprogression,项目名称:JabbR,代码行数:29,代码来源:Chat.cs
示例19: Typing
public void Typing(string roomName)
{
string id = GetUserId();
ChatUser user = _repository.GetUserById(id);
if (user == null)
{
return;
}
ChatRoom room = _repository.VerifyUserRoom(_cache, user, roomName);
UpdateActivity(user, room);
var userViewModel = new UserViewModel(user);
Clients[room.Name].setTyping(userViewModel, room.Name);
}
开发者ID:NTaylorMullen,项目名称:JabbR,代码行数:17,代码来源:Chat.cs
示例20: LeaveRoom
private void LeaveRoom(ChatUser user, ChatRoom room)
{
var userViewModel = new UserViewModel(user);
Clients[room.Name].leave(userViewModel, room.Name).Wait();
foreach (var client in user.ConnectedClients)
{
Groups.Remove(client.Id, room.Name).Wait();
}
OnRoomChanged(room);
}
开发者ID:NTaylorMullen,项目名称:JabbR,代码行数:12,代码来源:Chat.cs
注:本文中的JabbR.ViewModels.UserViewModel类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论