本文整理汇总了C#中JabbR.ViewModels.UserViewModel类的典型用法代码示例。如果您正苦于以下问题:C# UserViewModel类的具体用法?C# UserViewModel怎么用?C# UserViewModel使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
UserViewModel类属于JabbR.ViewModels命名空间,在下文中一共展示了UserViewModel类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MessageViewModel
public MessageViewModel(ChatMessage message)
{
Id = message.Id;
Content = message.Content;
User = new UserViewModel(message.User);
When = message.When;
}
示例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;
}
示例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;
}
示例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);
}
}
示例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);
}
示例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();
}
}
}
示例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;
}
示例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);
}
示例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);
}
示例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);
}
}
示例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);
}
}
示例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);
}
示例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);
}
}
}
示例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);
}
}
示例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));
}