private void PopulateChatRoom(ChatRoomModel roomDataData) { myScope.Model.Users = roomDataData.Users; if (roomDataData.Messages!=null) myScope.Model.ChatLines.AddRange(roomDataData.Messages); myScope.Apply(); }
public void CreateChatChannel(string roomName, UserLogicModel user, Action<ChatRoomModel> complete) { manager.client.Collection("ChatRoom", (err, collection) => { ChatRoomModel chatRoomModel = new ChatRoomModel(roomName, new List<UserLogicModel>() {user}, new List<ChatMessageRoomModel>()); collection.Insert(chatRoomModel); complete(chatRoomModel); }); }
public void RemoveUser(ChatRoomModel room, UserLogicModel user, Action<ChatRoomModel> complete) { manager.client.Collection("ChatRoom", (err, collection) => { JsDictionary<string, object> query = new JsDictionary<string, object>(); query["$pop"] = new {users = user}; collection.Update(new { _id = MongoDocument.GetID(room.ID) }, query, (err2) => { if (err2 != null) Logger.Log("Data Error: " + err2, LogLevel.Error); room.Users.Remove(user); complete(room); }); }); }
public void AddChatLine(UserLogicModel user, ChatRoomModel room, string message, Action<ChatMessageRoomModel> complete) { manager.client.Collection("ChatRoom", (err, collection) => { ChatMessageRoomModel messageModel = new ChatMessageRoomModel(user, message, DateTime.Now); JsDictionary<string, object> query = new JsDictionary<string, object>(); query["$push"] = new {messages = messageModel}; collection.Update(new { _id = MongoDocument.GetID(room.ID )}, query, (err2) => { if (err2 != null) Logger.Log("Data Error: " + err2,LogLevel.Error); room.Messages.Add(messageModel); complete(messageModel); }); }); }
private void leaveChatRoom(UserLogicModel user) { ExtensionMethods.debugger(); var room = getRoomFromUser(user); if (room == null) throw new Exception("idk"); foreach (var userLogicModel in room.Users) { if (userLogicModel.Hash == user.Hash) { room.Users.Remove(userLogicModel); break; } } myDataManager.ChatData.RemoveUser(room, user, (a) => { myServerManager.UnregisterChatServer(user); var roomToSend = new ChatRoomModel(room.RoomName, room.Users, null); foreach (var userLogicModel in room.Users) { myServerManager.SendChatInfo(userLogicModel, roomToSend); } }); }
private void PopulateChatRoom(ChatRoomModel roomData) { myRoomPlayers.ClearItems(); foreach (var userModel in roomData.Users) { myRoomPlayers.AddItem(new ShuffListItem(userModel.UserName, userModel.UserName)); } if (roomData.Messages != null) myChatBox.AddChatMessages(roomData.Messages); }
public void SendChatInfo(UserLogicModel user, ChatRoomModel response) { qManager.SendMessage(user.Gateway, "Area.Chat.ChatInfo.Response", user, new ChatRoomInfoModel(response)); }
public ChatRoomInfoModel(ChatRoomModel info) { Info = info; }
private void OnJoinChatChannel(UserLogicModel user, JoinChatRoomRequest data) { var cur = getRoomFromUser(user); if (cur != null) leaveChatRoom(user); ChatRoomModel currentRoom = null; foreach (var chatRoomModel in runningRooms) { if (chatRoomModel.RoomName == data.Room.ChatChannel) currentRoom = chatRoomModel; } if (currentRoom == null) throw new Exception("idk"); myDataManager.ChatData.AddUser(currentRoom, user, room => { myServerManager.RegisterChatServer(user); var roomToSend = new ChatRoomModel(room.RoomName, room.Users, room.Messages); roomToSend.Messages = room.Messages.Extract(room.Messages.Count - 5); myServerManager.SendChatInfo(user, roomToSend); roomToSend = new ChatRoomModel(room.RoomName, room.Users, null); foreach (var userLogicModel in currentRoom.Users) { myServerManager.SendChatInfo(userLogicModel, roomToSend); } }); }