Example #1
0
        public override async Task <ChatRooms> GetChatRooms(Lookup request, ServerCallContext context)
        {
            var result       = new ChatRooms();
            var allChatRooms = await _chatRooms.GetAll();

            result.ChatRooms_.AddRange(allChatRooms);
            return(result);
        }
Example #2
0
        public void DeleteChatRoom(Guid chatRoomId)
        {
            var chatRoom = ChatRooms.FirstOrDefault(i => i.ChatRoomID == chatRoomId);

            if (chatRoom != null)
            {
                _chatRooms.Remove(chatRoom);
            }
        }
Example #3
0
        public void DeleteChatRoom(RoomMode roomMode, string chatRoomName)
        {
            var chatRoom = ChatRooms.FirstOrDefault(i => i.ChatRoomName == chatRoomName && i.ChatRoomMode == roomMode);

            if (chatRoom != null)
            {
                _chatRooms.Remove(chatRoom);
            }
        }
Example #4
0
        public void Configuration(IAppBuilder app)
        {
            app.MapSignalR();
            ConfigureAuth(app);
            var idProvider = new PrincipalUserIdProvider();

            GlobalHost.DependencyResolver.Register(typeof(IUserIdProvider), () => idProvider);

            // restore all rooms which were created
            ChatRooms.RestoreRooms();
            //Session
        }
Example #5
0
        private void OnReadMessage(List <ChatMessage> obj)
        {
            var messages = from a in ChatRooms.SelectMany(x => x.Conversations)
                           join d in obj on a.SenderId equals d.SenderId
                           select a;

            foreach (var item in messages.ToList())
            {
                item.Readed = true;
            }
            Refresh();
        }
Example #6
0
        public async Task CreateRoom(string room)
        {
            if (!string.IsNullOrEmpty(room))
            {
                var newRoom = new ChatRooms {
                    Name = room
                };
                await _roomRep.Add(newRoom);

                await Clients.All.SendAsync("room", newRoom);
            }
        }
Example #7
0
        public void Process(Context context)
        {
            var clientPrefs = new Unknown10();

            context.SendAndProcessMessage(clientPrefs);

            var groups = new Groups();

            context.SendAndProcessMessage(groups);

            var groupsFriends = new GroupsFriends();

            context.SendAndProcessMessage(groupsFriends);

            var serverList = new ServerList();

            context.SendAndProcessMessage(serverList);

            var chatRooms = new ChatRooms();

            context.SendAndProcessMessage(chatRooms);

            var friendsList = new FriendsList(context.User);

            context.SendAndProcessMessage(friendsList);

            var friendsStatus = new FriendsSessionAssign(context.User);

            context.SendAndProcessMessage(friendsStatus);

            // Tell friends this user came online
            //if (context.User.Username == "test") Debugger.Break();
            var friends = context.Server.Database.QueryFriends(context.User);

            friends.ForEach(friend =>
            {
                var otherSession = context.Server.GetSession(friend);
                if (otherSession != null)
                {
                    otherSession.SendAndProcessMessage(new FriendsSessionAssign(friend));
                }
            });

            var pendingFriendRequests = context.Server.Database.QueryPendingFriendRequests(context.User);

            pendingFriendRequests.ForEach(request =>
            {
                var requester = context.Server.Database.QueryUser(request.UserId);
                context.SendAndProcessMessage(new FriendInvite(requester.Username, requester.Nickname, request.Message));
            });
        }
Example #8
0
        public IChatRoom AddChatRoom(IChatRoom chatRoom)
        {
            var foundChatRoom = ChatRooms.FirstOrDefault(i => (i.ChatRoomName == chatRoom.ChatRoomName && i.ChatRoomMode == chatRoom.ChatRoomMode) || (i.ChatRoomID == chatRoom.ChatRoomID));

            if (foundChatRoom == null)
            {
                _chatRooms.Add(chatRoom);
                return(chatRoom);
            }
            else
            {
                return(null);
            }
        }
        private void SetChatRooms(GitterChatRoom[] rooms)
        {
            IEnumerable <GroupedMenuItem> intermediate;

            if (rooms == null || rooms.Length == 0)
            {
                intermediate = new GroupedMenuItem[0];
            }
            else
            {
                if (SearchGitter)
                {
                    intermediate = new[]
                    {
                        new GroupedMenuItem(AppResources.MenuGroupSearchResults, rooms.Where(r => !r.IsSuggestion)),
                        new GroupedMenuItem(AppResources.MenuGroupSuggestions, rooms.Where(r => r.IsSuggestion)),
                    };
                }
                else
                {
                    intermediate = new[]
                    {
                        new GroupedMenuItem(AppResources.MenuGroupStarredUnreads, rooms.Where(r => r.IsStarred && r.HasUnread).OrderBy(r => r.Room.FavouriteIndex)),
                        new GroupedMenuItem(AppResources.MenuGroupUnreads, rooms.Where(r => !r.IsStarred && r.HasUnread).OrderBy(r => r.Name.ToUpperInvariant())),
                        new GroupedMenuItem(AppResources.MenuGroupStarred, rooms.Where(r => r.IsStarred && !r.HasUnread).OrderBy(r => r.Room.FavouriteIndex)),
                        new GroupedMenuItem(AppResources.MenuGroupRooms, rooms.Where(r => !r.IsStarred && !r.HasUnread && !r.IsPerson).OrderBy(r => r.Name.ToUpperInvariant())),
                        new GroupedMenuItem(AppResources.MenuGroupDirects, rooms.Where(r => !r.IsStarred && !r.HasUnread && r.IsPerson).OrderBy(r => r.Name.ToUpperInvariant()))
                    };
                }
            }

            // remove empty items
            var results = intermediate.Where(g => g.Any()).ToArray();

            // handle no items
            if (results.Length == 0)
            {
                results = new[] { new GroupedMenuItem(AppResources.MenuGroupNoResults) };
            }

            // update the UI
            ChatRooms.Clear();
            var groups = new ObservableCollection <GroupedMenuItem>(results);

            foreach (var group in groups)
            {
                ChatRooms.Add(group);
            }
        }
Example #10
0
        private async void GetProfile()
        {
            var contactService = new ContactService();
            var result         = await contactService.GetProfile(MyAccount.IdUser);

            if (result != null && result.Contacts != null)
            {
                foreach (var item in result.Contacts)
                {
                    var room = new ConversationRoom(ConversationType.Private, MyAccount, item);
                    room.OnSendMessage += Room_OnSendMessage;
                    ChatRooms.Add(room);
                }
            }
        }
Example #11
0
        public async void SetCurrentRoom(int contactId)
        {
            var room = ChatRooms.Where(x => x.UserId == contactId).FirstOrDefault();

            if (room == null)
            {
                var userAccount = MyAccount.Contacts.Where(x => x.UserId == contactId).FirstOrDefault();
                if (userAccount != null)
                {
                    room = new ConversationRoom(ConversationType.Private, MyAccount, userAccount);
                    room.OnSendMessage += Room_OnSendMessage;
                    this.ChatRooms.Add(room);
                }
            }

            CurrentRoom = room;

            if (CurrentRoom != null && CurrentRoom.Conversations != null && CurrentRoom.Conversations.Count <= 0)
            {
                var conversationService = new ConversationService();
                var chatRoom            = await conversationService.GetConversations(MyAccount.IdUser, contactId);

                if (chatRoom != null)
                {
                    foreach (var item in chatRoom.Messages)
                    {
                        CurrentRoom.Conversations.Add(item);
                    }
                }
            }



            if (CurrentRoom != null && CurrentRoom.Conversations != null)
            {
                var unReaded = CurrentRoom.Conversations.Where(x => x.SenderId == CurrentRoom.UserId && x.Readed == false).ToList();
                if (unReaded != null && unReaded.Count() > 0)
                {
                    foreach (var item in unReaded)
                    {
                        item.Readed = true;
                    }
                    await ReadMessage(unReaded.ToList());
                }
            }

            this.Refresh();
        }
Example #12
0
        public JsonResult RecentChatMessages()
        {
            var crs = new ChatRooms();

            crs.GetRecentChatMessages();

            var sb = new StringBuilder();

            foreach (ChatRoom cnt in crs)
            {
                sb.Append(cnt.ToUnorderdListItem);
            }

            return Json(new
            {
                ListItems = sb.ToString()
            });
        }
Example #13
0
        public List <IChatRoom> GetChatRooms(RoomMode roomMode)
        {
            var chatRooms = ChatRooms.Where(i => i.ChatRoomMode == roomMode).ToList();

            foreach (var room in chatRooms)
            {
                var activeUsers = room.CurrentUsers.Count(i => i.IsActive);

                if (activeUsers == 0)
                {
                    DeleteChatRoom(room.ChatRoomID);
                }
            }

            chatRooms = ChatRooms.Where(i => i.ChatRoomMode == roomMode).ToList();

            return(chatRooms);
        }
Example #14
0
 public virtual void Dispose(bool disposing)
 {
     if (this._disposed)
     {
         return;
     }
     if (disposing)
     {
         Context.Dispose();
         UserManager.Dispose();
         ChatMessages.Dispose();
         ChatRooms.Dispose();
         ChatRoomUsers.Dispose();
         Friends.Dispose();
         PrivateMessages.Dispose();
     }
     this._disposed = true;
 }
Example #15
0
        public override async Task Process(IXFireClient context)
        {
            var clientPrefs = new Unknown10();
            await context.SendAndProcessMessage(clientPrefs);

            var groups = new Groups();
            await context.SendAndProcessMessage(groups);

            var groupsFriends = new GroupsFriends();
            await context.SendAndProcessMessage(groupsFriends);

            var serverList = new ServerList();
            await context.SendAndProcessMessage(serverList);

            var chatRooms = new ChatRooms();
            await context.SendAndProcessMessage(chatRooms);

            var friendsList = new FriendsList(context.User);
            await context.SendAndProcessMessage(friendsList);

            var friendsStatus = new FriendsSessionAssign(context.User);
            await context.SendAndProcessMessage(friendsStatus);

            // Tell friends this user came online
            //if (context.User.Username == "test") Debugger.Break();
            var friends = await context.Server.Database.QueryFriends(context.User);

            foreach (var friend in friends)
            {
                var otherSession = context.Server.GetSession(friend);
                if (otherSession != null)
                {
                    await otherSession.SendAndProcessMessage(new FriendsSessionAssign(friend));
                }
            }

            var pendingFriendRequests = await context.Server.Database.QueryPendingFriendRequests(context.User);

            foreach (var request in pendingFriendRequests.Select(request => new FriendInvite(request.Username, request.Nickname, request.Message)))
            {
                await context.SendAndProcessMessage(request);
            }
        }
        public ActionResult AddUserInGroup(int id)
        {
            Users     mainUser = db.Users.FirstOrDefault(u => u.Login == HttpContext.User.Identity.Name);
            Users     user     = db.Users.Find(id);
            ChatRooms chatRoom = new ChatRooms {
                NameRoom = user.Login + HttpContext.User.Identity.Name
            };

            db.ChatRooms.Add(chatRoom);
            db.SaveChanges();
            mainUser.UserInChatRoom.Add(new UserInChatRoom {
                ChatRoomId = chatRoom.ChatRoomId, UserId = mainUser.UserId
            });
            user.UserInChatRoom.Add(new UserInChatRoom {
                ChatRoomId = chatRoom.ChatRoomId, UserId = user.UserId
            });
            db.SaveChanges();

            return(RedirectToAction("MessagesUser", new { groupName = chatRoom.NameRoom }));
        }
Example #17
0
        public async Task CreateRoom()
        {
            if (string.IsNullOrEmpty(NewRoomName))
            {
                return;
            }
            var newChatRoom = new ChatRoomDto
            {
                Name = NewRoomName
            };

            newChatRoom.Id = ChatFacade.CreateChatRoom(newChatRoom);
            ChatRooms.Add(newChatRoom);
            NewRoomName = "";

            await Service.ChangeViewModelForConnectionsAsync(
                (ChatViewModel viewModel) => { viewModel.ChatRooms.Add(newChatRoom); },
                ChatFacade.GetAllConnectedUsers()
                .Select(s => s.ConnectionId)
                .ToList());
        }
Example #18
0
        private async void OnRecieveMessageFrom(ChatMessage obj)
        {
            if (CurrentRoom != null && obj.SenderId == CurrentRoom.UserId)
            {
                obj.Readed = true;
                CurrentRoom.Conversations.Add(obj);
                await  ReadMessage(new List <ChatMessage> {
                    obj
                });

                Refresh();
            }
            else
            {
                var room = ChatRooms.Where(x => x.UserId == obj.SenderId).FirstOrDefault();
                if (room != null)
                {
                    room.Conversations.Add(obj);
                }
            }
        }
        public override async Task Process(IXFireClient context)
        {
            var clientPrefs = new Unknown10();
            await context.SendAndProcessMessage(clientPrefs);

            var groups = new Groups();
            await context.SendAndProcessMessage(groups);

            var groupsFriends = new GroupsFriends();
            await context.SendAndProcessMessage(groupsFriends);

            var serverList = new ServerList();
            await context.SendAndProcessMessage(serverList);

            var chatRooms = new ChatRooms();
            await context.SendAndProcessMessage(chatRooms);

            // TODO: Remove chat room mode
            var otherUsers = await context.Server.Database.AddEveryoneAsFriends(context.User);

            var friendsList = new FriendsList(context.User);
            await context.SendAndProcessMessage(friendsList);

            var friendsStatus = new FriendsSessionAssign(context.User);
            await context.SendAndProcessMessage(friendsStatus);

            // TODO: Remove chat room mode
            foreach (var otherUser in otherUsers)
            {
                var otherSession = context.Server.GetSession(otherUser);
                if (otherSession != null)
                {
                    await otherSession.SendAndProcessMessage(new FriendsList(otherSession.User));

                    await otherSession.SendMessage(
                        FriendsSessionAssign.UserCameOnline(context.User, context.SessionId));
                }
            }
        }
Example #20
0
 public void Stop()
 {
     //EventCommunicator.SendSimStopEvent();
     //handshakeManagerThread.Abort();
     if (coordinatorThread != null)
     {
         coordinatorThread.Abort();
     }
     if (eCommReceiver != null)
     {
         eCommReceiver.Abort();
     }
     //textChatServerThread.Abort();
     HappeningList.Happenings.Clear();
     TimerQueueClass.Clear();
     IncomingList.Clear();
     Genealogy.Clear();
     StatesForUnits.Clear();
     UnitFacts.CurrentUnitStates.Clear();
     UnitFacts.ClearDMTables();
     UnitFacts.Data.Clear();
     ChatRooms.DropAllRooms();
     VoiceChannels.DropAllChannels();
     WhiteboardRooms.DropAllRooms();
     TimerControl((int)TimerControls.Reset);
     //        ScenarioToQueues.Reset();
     WeaponTable.Clear();
     NetworkTable.Clear();
     SubplatformRecords.Clear();
     Engrams.Clear();
     Scores.Clear();
     DebugLogger.StopLogging();
     NameLists.Clear();
     DecisionMakerType.ClearDMTable();
     SpeciesType.ClearSpeciesTable();
     Metronome.GetInstance().CleanupMetronome();
 }
Example #21
0
        public override void AfterInvoke(InvocationInfo info, ref object returnValue)
        {
            if (info.target is ChatRooms && info.targetMethod.Equals("SetRoomInfo"))
            {
                RoomInfoMessage roomInfo = (RoomInfoMessage)info.arguments[0];
                if (!userNameToUserCache.ContainsKey(roomInfo.roomName))
                {
                    userNameToUserCache.Add(roomInfo.roomName, new Dictionary<string, ChatUser>());
                }
                Dictionary<string, ChatUser> userCache = userNameToUserCache[roomInfo.roomName];
                userCache.Clear();
                RoomInfoProfile[] profiles = roomInfo.updated;
                for (int i = 0; i < profiles.Length; i++)
                {
                    RoomInfoProfile p = profiles[i];
                    ChatUser user = ChatUser.FromRoomInfoProfile(p) ;
                    userCache.Add(user.name, user);
                    if (!globalusers.ContainsKey(user.name)) { globalusers.Add(user.name, user); };
                }

                
                
            }
            /*else if (info.target is ChatUI && info.targetMethod.Equals("Initiate"))
            {
                Console.WriteLine("Initialize#");
                if (target != (ChatUI)info.target)
                {
                    chatRooms = (ChatRooms)chatRoomsinfo.GetValue(info.target);
                    target = (ChatUI)info.target;
                }

            }*/

            else if (info.target is ChatUI && info.targetMethod.Equals("OnGUI"))
            {
                if (target != (ChatUI)info.target)
                {
                    chatRooms = (ChatRooms)chatRoomsinfo.GetValue(info.target);
                    target = (ChatUI)info.target;
                    
                }
                
                RoomLog currentRoomChatLog = chatRooms.GetCurrentRoomChatLog();
                if (currentRoomChatLog != null)
                {

                    if (!(chatRooms.GetCurrentRoom().name == this.currentroom)) { this.currentroom = chatRooms.GetCurrentRoom().name; recalc = true; }

                    Vector2 screenMousePos = GUIUtil.getScreenMousePos();
                    Rect chatlogAreaInner = new Rect((Rect)chatlogAreaInnerinfo.GetValue(info.target));

                    // delete picture on click!
                    if ((Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1)) && this.clicked == false) { this.clearallpics(); }

                    if (chatlogAreaInner.Contains(screenMousePos) && (Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1)) && this.clicked == false)
                    { this.clicked=true;}
                    

                    if (!(Input.GetMouseButtonUp(0) || Input.GetMouseButtonUp(1)) && this.clicked)
                    {
                        this.clicked = false;

                        if (!(Screen.height == screenh) || !(Screen.width == screenw)) // if resolution was changed, recalc positions
                        {
                            recalc = true;
                            screenh = Screen.height;
                            screenw = Screen.width;
                        }

                        timeStampStyle = (GUIStyle)timeStampStyleinfo.GetValue(info.target);
                        chatLogStyle = (GUIStyle)chatLogStyleinfo.GetValue(info.target);

                        bool allowSendingChallenges = (bool)allowSendingChallengesinfo.GetValue(info.target);

                        Gui.ContextMenu<ChatUser> userContextMenu = (Gui.ContextMenu<ChatUser>)userContextMenuinfo.GetValue(info.target);
                        WeeklyWinner[] weeklyWinners = (WeeklyWinner[])weeklyWinnerInfo.GetValue(info.target);
                        float maxScroll = (float)maxScrollinfo.GetValue(info.target);

                        int posy = 0;//

                        float width = (chatlogAreaInner.width - (float)Screen.height * 0.1f - 20f);
                        int globalfromxstart = (int)chatlogAreaInner.xMin + (int)(20f + (float)Screen.height * 0.042f) + 10;
                        int normlhight = (int)chatLogStyle.CalcHeight(new GUIContent("lol"), width);
                        float diff = GUI.skin.label.CalcHeight(new GUIContent("lol"), width) - chatLogStyle.CalcHeight(new GUIContent("lol"), width);
                        if (recalc) // recalc positions
                        {
                            this.roomuserlist.Clear();
                            //this.roomlinklist.Clear();


                            recalc = false;
                            

                            foreach (RoomLog.ChatLine current in currentRoomChatLog.GetLines())
                            {
                                logentry templog = new logentry();
                                //delete html

                                
                                String shorttxt = Regex.Replace(current.text, @"(<color=#[A-Za-z0-9]{0,6}>)|(</color>)", String.Empty);
                                templog.msg = current.text;

                                
                                templog.from = shorttxt.Split(':')[0];
                                templog.admin = false; //for testing true
                                if (current.senderAdminRole == AdminRole.Mojang || current.senderAdminRole == AdminRole.Moderator || current.senderFeatureType == FeatureType.DEMO)
                                {
                                    templog.admin = true;
                                }
                                if (!templog.admin)
                                {
                                    if (weeklyWinners != null && weeklyWinners.Length >= 4)
                                    {
                                        for (int i = 0; i < 4; i++)
                                        {
                                            if (current.from == weeklyWinners[i].userName)
                                            {
                                                templog.admin = true;
                                                break;
                                            }
                                        }
                                    }
                                }

                                chatLogStyle.wordWrap = false;// need to do this, or length of calcsize is wrong.. lol!!!
                                
                                Vector2 v = GUI.skin.label.CalcSize(new GUIContent(templog.from + ":"));//calc length of "username:"******"iiii " has the same length like the symbol
                                    v = GUI.skin.label.CalcSize(new GUIContent("iiii " + templog.from + ":"));//calc length of "username:"******" " + shorttxt + " " + msgheight);
                                int fromxend = (int)v.x + globalfromxstart;
                                templog.usernamelength = (int)v.x;
                                int fromystart = posy;
                                int fromyend = posy + normlhight;//(int)v.y
                                templog.end = posy + (int)msgheight +2;//2 is added after each msg
                                posy += (int)msgheight +2;
                                templog.userrec = new Rect(globalfromxstart, fromystart, fromxend - globalfromxstart, fromyend - fromystart);
                                this.roomuserlist.Add(templog);

                                //Console.WriteLine(current.text+" "+templog.from +" "+shorttxt+" " + v.x + " " + fromxend + " " + msgheight + " " + posy);
                                //Console.WriteLine(msgheight + " old:" + test123);
                                //Console.WriteLine("##");
                            }



                        }
                        else { posy = this.posycopy; }
                        this.posycopy = posy;
                        Vector2 chatScroll = Vector2.zero + (Vector2)chatScrollinfo.GetValue(info.target);
                        int chatlength = Math.Max(posy + (int)chatlogAreaInner.yMin + 1, (int)chatlogAreaInner.yMax);//take the chatlogareainner.y if msg doesnt need scrollbar (cause its to short)
                        //Maxscroll is FALSE! if you have a small window, with scollbar, and resize it maxscroll wont get lower
                        int truemaxscroll = Math.Max(chatlength - (int)chatlogAreaInner.yMax, 1);//minimum 1 else dividing by zero
                        //calculate upper y-value (=0 if chatscroll.y=0 and =chatlength-yMax if chatscroll.y=truemaxscroll)
                        int currentuppery = (int)((chatlength - (int)chatlogAreaInner.yMax) * (chatScroll.y / truemaxscroll));
                        //calculate mouseposy in chatbox (if maus klicks in the left upper edge of chatlogareainner with scrollbar on the top, the value is zero ) 
                        int realmousy = currentuppery + (int)screenMousePos.y - (int)chatlogAreaInner.yMin;
                        //Console.WriteLine("border chatinner: " + chatlogAreaInner.xMin + " " + chatlogAreaInner.yMin + " " + chatlogAreaInner.xMax + " " + chatlogAreaInner.yMax);
                        //Console.WriteLine("fontsize: " + chatLogStyle.fontSize);
                        //Console.WriteLine("maus " + screenMousePos.x + " " + realmousy);
                        Vector2 mousepos = new Vector2(screenMousePos.x, realmousy);

                        // is an username is clicked?
                        foreach (logentry log in roomuserlist)
                        {
                            Rect usrbutton = log.userrec;
                            if (usrbutton.Contains(mousepos))
                            {
                                //Console.WriteLine("userrecx " + log.userrec.xMin+" "+log.userrec.xMax);
                                //Console.WriteLine("klicked: " + log.from);
                                //##################
                                string sender = log.from;
                                ChatUser user;
                                bool foundUser = globalusers.TryGetValue(sender, out user);
                                if (foundUser)
                                {
                                    user.acceptChallenges = false;
                                    user.acceptTrades = true;
                                    this.CreateUserMenu(user, info.target,log.usernamelength);
                                    App.AudioScript.PlaySFX("Sounds/hyperduck/UI/ui_button_click");
                                }
                                //##################
                                break;
                            }
                            if (mousepos.y >= usrbutton.yMin && mousepos.y <= log.end) 
                            {
                                
                                string klickedword = whitchwordclicked(log.msg, chatLogStyle, width, normlhight, globalfromxstart, (int)usrbutton.yMin+2, mousepos, log.admin);
                                //clickable link?

                                if (klickedword.StartsWith("{\"deck\":\"") && klickedword.EndsWith("]}") && klickedword.Contains("\",\"types\":["))
                                {
                                    //is a deck-link! 
                                    this.copyDeckMenu(null, klickedword);
                                    App.AudioScript.PlaySFX("Sounds/hyperduck/UI/ui_button_click");
                                }

                                Match match = linkFinder.Match(klickedword);
                                if (match.Success)
                                {
                                    string link = match.Value;
                                    if (!(link.StartsWith(@"https://")) && !(link.StartsWith(@"http://"))) { link = "http://" + link; }
                                    this.CreateLinkMenu(null, link);
                                    App.AudioScript.PlaySFX("Sounds/hyperduck/UI/ui_button_click");
                                }
                                //clickable card?

                                cardsearcher cmatch = searchcard(klickedword);
                                //Match mutch=cardlinkfinder.Match(klickedword);
                                //if (mutch.Success)
                                if (cmatch.success)
                                {
                                    //string clink = mutch.Value.ToLower();
                                    //clink = clink.Replace("[","");
                                    //clink = clink.Replace("]", "");
                                    //clink = clink.Replace("_", " ");
                                    string clink = cmatch.clickedcardname;
                                    Console.WriteLine("CARDCLICKED: " + clink);
                                    int arrindex = Array.FindIndex(this.cardnames, element => element.Equals(clink));
                                    if (arrindex >= 0)
                                    {

                                        CardType type = CardTypeManager.getInstance().get(this.cardids[arrindex]);
                                        Card card = new Card(cardids[arrindex], type, false);
                                        UnityEngine.Object.Destroy(this.cardRule);
                                        cardRule = PrimitiveFactory.createPlane();
                                        cardRule.name = "CardRule";
                                        CardView cardView = cardRule.AddComponent<CardView>();
                                        cardView.init(this,card,0);
                                        cardView.applyHighResTexture();
                                        cardView.setLayer(8);
                                        Vector3 vccopy = Camera.main.transform.localPosition;
                                        Camera.main.transform.localPosition = new Vector3(0f , 1f , -10f);
                                        cardRule.transform.localPosition = Camera.main.ScreenToWorldPoint(new Vector3((float)Screen.width * 0.87f, (float)Screen.height * 0.6f, 0.9f)); ;
                                        //cardRule.transform.localPosition = Camera.main.ScreenToWorldPoint(new Vector3((float)Screen.width * 0.57f, (float)Screen.height * 0.6f, 0.9f)); ;
                                        
                                        cardRule.transform.localEulerAngles = new Vector3(90f, 180f, 0f);//90 180 0
                                        cardRule.transform.localScale = new Vector3(9.3f, 0.1f, 15.7f);// CardView.CardLocalScale(100f);
                                        cardtext=cardRule.renderer.material.mainTexture;
                                        Vector3 ttvec1 = Camera.main.WorldToScreenPoint(cardRule.renderer.bounds.min);
                                        Vector3 ttvec2 = Camera.main.WorldToScreenPoint(cardRule.renderer.bounds.max);
                                        Rect ttrec = new Rect(ttvec1.x, Screen.height - ttvec2.y, ttvec2.x - ttvec1.x, ttvec2.y - ttvec1.y);
                                        
                                        scalefactor =  (float)(Screen.height/1.9)/ttrec.height;
                                        cardRule.transform.localScale = new Vector3(cardRule.transform.localScale.x * scalefactor, cardRule.transform.localScale.y, cardRule.transform.localScale.z * scalefactor);
                                         ttvec1 = Camera.main.WorldToScreenPoint(cardRule.renderer.bounds.min);
                                         ttvec2 = Camera.main.WorldToScreenPoint(cardRule.renderer.bounds.max);
                                         ttrec = new Rect(ttvec1.x, Screen.height - ttvec2.y, ttvec2.x - ttvec1.x, ttvec2.y - ttvec1.y);
                                        cardrect = ttrec;
                                        gettextures(cardView);
                                        mytext = true;
                                        Camera.main.transform.localPosition=vccopy;


                                    }
                                
                                }

                            }
                            if (mousepos.y < log.end) { break; };

                        }//foreach (logentry log in liste) end 

                        // is link klicked
                        /*Rect lastrec = new Rect();
                        foreach (linkdata log in roomlinklist)
                        {
                            Rect[] usrbutton = log.linkrec;
                            bool contain = false;
                            foreach (Rect rec in usrbutton)
                            {
                                
                                contain = contain || rec.Contains(mousepos);
                                lastrec = rec;
                                //Console.WriteLine(contain + " " + rec.ToString());
                            }
                            if (contain)
                            {
                                string link = log.link;

                                //user.acceptChallenges = false;
                                //user.acceptTrades = true;
                                this.CreateLinkMenu(null, link);
                                App.AudioScript.PlaySFX("Sounds/hyperduck/UI/ui_button_click");



                                //##################
                                break;
                            }
                            if (mousepos.y < lastrec.yMax) { break; };

                        }*/

                        
                    }

                    // draw cardoverlay again!
                    if (mytext)
                    {
                        GUI.depth =1;
                        Rect rect = new Rect(100,100,100,Screen.height-200);
                        foreach (cardtextures cd in this.gameObjects)
                        {
                            GUI.DrawTexture(cd.cardimgrec, cd.cardimgimg); }

                        foreach (renderwords rw in this.textsArr)
                        {
                            
                            float width =rw.style.CalcSize(new GUIContent(rw.text)).x;
                           GUI.matrix = Matrix4x4.TRS(new Vector3(0, 0, 0),
                            Quaternion.identity, new Vector3(rw.rect.width / width, rw.rect.width / width, 1));
                            
                           Rect lol = new Rect(rw.rect.x * width / rw.rect.width, rw.rect.y * width / rw.rect.width, rw.rect.width * width / rw.rect.width, rw.rect.height * width / rw.rect.width);
                           GUI.contentColor = rw.color;
                           GUI.Label(lol, rw.text, rw.style);
                            
                        }

                    }
                    
                    
                }
            }

            /*
            else if (info.target is ChatRooms && info.targetMethod.Equals("ChatMessage"))
            {
                Console.WriteLine("chatmessage inc##");
                RoomChatMessageMessage msg = (RoomChatMessageMessage)info.arguments[0];
                if (msg.roomName == chatRooms.GetCurrentRoom().name)
                //if (((string)info.arguments[0]) == chatRooms.GetCurrentRoom().name)
                {
                    this.recalc = true;
                }
            }
            */

            else if (info.target is ArenaChat && info.targetMethod.Equals("handleMessage"))
            {
                Message msg = (Message)info.arguments[0];
                if (msg is WhisperMessage)
                {
                    WhisperMessage whisperMessage = (WhisperMessage)msg;
                    if (whisperMessage.GetChatroomName() == chatRooms.GetCurrentRoom().name)
                    {
                        this.recalc = true;
                    }
                }
                if (msg is RoomChatMessageMessage)
                {
                    RoomChatMessageMessage mssg = (RoomChatMessageMessage)msg;
                    if (mssg.roomName == chatRooms.GetCurrentRoom().name)
                    {
                        this.recalc = true;
                    }
                }
            
            }



            return;
        }
        public ActionResult GetActiveChatRooms()
        {
            var rooms = ChatRooms.GetAll();

            return(View(rooms));
        }
 public ActionResult RestoreRooms()
 {
     ViewBag.Number = ChatRooms.RestoreRooms();
     return(View());
 }
Example #24
0
        public override void AfterInvoke (InvocationInfo info, ref object returnValue)
        
        {
            if (info.target is GameSocket && info.targetMethod.Equals("OnDestroy")) {
                gdata.sendOffline(); 
            }

            if (info.target is ChatUI && info.targetMethod.Equals("Show")) { this.chatisshown = (bool)info.arguments[0]; }

            if (info.target is MainMenu && info.targetMethod.Equals("OnGUI"))
            {
                GUI.depth = 21;
                GUIPositioner subMenuPositioner = App.LobbyMenu.getSubMenuPositioner(1f, 5);
                this.guildbutton = new Rect(subMenuPositioner.getButtonRect(0f));
                if (LobbyMenu.drawButton(this.guildbutton, "Guild", this.lobbyskin))
                {
                    this.inGuildmenu = !this.inGuildmenu;
                    ggui.reset();
                    targetchathightinfo.SetValue(App.ChatUI, (float)Screen.height * 0.25f);
                }
                if (this.inGuildmenu)
                {
                    //ggui.cardListPopupBigLabelSkin.label.fontSize = (int)(this.fieldHeight / 1.7f);
                    //ggui.cardListPopupSkin.label.fontSize = (int)(this.fieldHeight / 2.5f);
                    recto.setupPositions(this.chatisshown, 1.0f, this.chatLogStyle, ggui.cardListPopupSkin);
                    ggui.drawgui(this.chatLogStyle);
                }

            }
            
            if (info.target is ChatUI && (info.targetMethod.Equals("Initiate") || info.targetMethod.Equals("Awake")))
            {
                
                this.chatrooms = App.ArenaChat.ChatRooms;
                this.chatLogStyle = (GUIStyle)chatLogStyleinfo.GetValue(info.target);
                if (gdata.guildroom != "")
                {
                    openGuildChatWindow(); 
                }
            }

            if (info.target is ChatUI && info.targetMethod.Equals("OnGUI") )
            {
                string typingmessage = (string)chatmsg.GetValue(info.target);
                if (chatrooms.GetCurrentRoomName() == null) return;
                if ((this.chatrooms.GetCurrentRoomName()).Equals(gdata.guildroom) || typingmessage.StartsWith("/g") || typingmessage.StartsWith("\\g"))
                {
                    if (!(typingmessage.StartsWith("/g") || typingmessage.StartsWith("\\g")))
                    {
                        typingmessage = "/g " + typingmessage;
                    }

                    if (typingmessage != this.oldtyping && typingmessage.Length>=50)
                    {
                        string result = cry.Encrypt(typingmessage);
                        if (result.Length >= 512)
                        {
                            chatmsg.SetValue(info.target,oldtyping);
                        }
                        else
                        {
                            this.oldtyping = typingmessage;
                        }
                    }
                }
            }

            return;
        }
Example #25
0
 public List <IChatRoom> GetSessionChatRooms(string sessionId, RoomMode chatRoomMode)
 {
     return(ChatRooms.Where(i => i.ChatRoomMode == chatRoomMode && i.CurrentUsers.Any(j => j.SessionID == sessionId)).ToList());
 }
Example #26
0
 public IChatRoom GetChatRoom(RoomMode roomMode, string chatRoomName)
 {
     return(ChatRooms.FirstOrDefault(i => i.ChatRoomMode == roomMode && i.ChatRoomName == chatRoomName));
 }
Example #27
0
 public IChatRoom GetChatRoomWithUsers(RoomMode roomMode, List <ChatUser> chatUsers)
 {
     return(ChatRooms.FirstOrDefault(i => i.ChatRoomMode == roomMode && chatUsers.TrueForAll(j => i.CurrentUsers.Contains(j))));
 }
Example #28
0
        public IChatRoom GetOrCreateChatRoom(RoomMode roomMode, string chatRoomName, ChatUser chatUser)
        {
            IChatRoom chatRoom = null;

            switch (roomMode)
            {
            case RoomMode.Private:
            {
                chatRoom = ChatRooms.FirstOrDefault(i => i.ChatRoomName == chatRoomName && i.ChatRoomMode == roomMode && i.CurrentUsers.Any(j => j.SessionID == chatUser.SessionID));

                if (chatRoom == null)
                {
                    var newChatRoom = new PrivateChatRoom(chatRoomName);
                    newChatRoom.JoinChatRoom(chatUser);

                    chatRoom = AddChatRoom(newChatRoom);
                }
            }
            break;

            case RoomMode.Public:
            {
                chatRoom = ChatRooms.FirstOrDefault(i => i.ChatRoomName == chatRoomName && i.ChatRoomMode == roomMode);

                if (chatRoom == null)
                {
                    var newChatRoom = new PublicChatRoom(chatRoomName);
                    newChatRoom.JoinChatRoom(chatUser);

                    chatRoom = AddChatRoom(newChatRoom);
                }
            }
            break;
            }

            if (chatRoom != null)
            {
                var foundChatUser = chatRoom.CurrentUsers.FirstOrDefault(i => i.SessionID == chatUser.SessionID);

                if (foundChatUser == null)
                {
                    chatRoom.JoinChatRoom(chatUser);
                }
                else
                {
                    if (foundChatUser.IsActive)
                    {
                        if (!string.IsNullOrEmpty(chatUser.NickName) && chatUser.NickName != foundChatUser.NickName)
                        {
                            foundChatUser.NickName = chatUser.NickName;
                        }
                    }
                    else
                    {
                        chatRoom.RemoveUser(foundChatUser);

                        foreach (var room in ChatRooms)
                        {
                            room.RemoveUser(foundChatUser);
                        }

                        return(null);
                    }
                }
            }

            return(chatRoom);
        }
Example #29
0
        public static void SendTimeTick(object timeObj)
        {
            /* 2. Send the tick */
            //  timer += updateIncrement;
            int          time           = (int)timeObj;
            int          timer          = time / 1000;
            int          secs           = timer % 60;
            int          mins           = (timer / 60) % 60;
            int          hours          = timer / 3600;
            const string name_Space     = TimerTicker.name_Space;
            DateTime     currTime       = new DateTime(1, 1, 1, hours, mins, secs);
            string       simulationTime = String.Format("{0:HH:mm:ss}", currTime);

            EventCommunicator.SendEvent(new TickEventType(time, simulationTime));
            //   current = DateTime.Now;
            //   TimeSpan ts = current - last;
            //   Console.WriteLine("timeslice: {0:+hh.mm.ss.ffffzz}", ts.ToString());
            //last = current;

            /* 3. Pull the events for this tick off the queue and handle them */
            List <ScenarioEventType> events = TimerQueueClass.RetrieveEvents(timer);

            if (events != null)
            {
                for (int v = 0; v < events.Count; v++)
                {
                    Coordinator.debugLogger.Writeline("Timer", "Time: " + time.ToString()
                                                      + "  ID: " + events[v].UnitID.ToString() +
                                                      " Event: " + events[v].GetType().ToString(), "test");
                    // track current state
                    if (UnitFacts.AnyDead(events[v].AllUnits))
                    {// skip an event that refers to a dead unit
                        continue;
                    }
                    string thisUnit   = events[v].UnitID;
                    string thisTarget = "";
                    // Only a few outgoing events require two substitutions
                    switch (events[v].GetType().ToString())
                    {
                    case name_Space + "AttackObjectEvent":
                        thisTarget = ((AttackObjectEvent)events[v]).TargetObjectID;
                        break;

                    case name_Space + "LaunchEventType":
                        thisTarget = ((LaunchEventType)events[v]).Child;
                        break;

                    case name_Space + "WeaponLaunchEventType":
                        thisTarget = ((WeaponLaunchEventType)events[v]).Child;
                        break;

                    case name_Space + "SubplatformLaunchType":
                        thisTarget = ((SubplatformLaunchType)events[v]).ParentUnit;
                        break;

                    case name_Space + "SubplatformDockType":
                        thisTarget = ((SubplatformDockType)events[v]).ParentUnit;
                        break;

                    default:
                        break;
                    }

                    if (!events[v].EngramValid(thisUnit, thisTarget))
                    {
                        Coordinator.debugLogger.Writeline("Timer", "Time: Command" + events[v].GetType().ToString() + " ignored due to value of " + events[v].Range.Name, "test");
                    }
                    else
                    {
                        switch (events[v].GetType().ToString())
                        {
                        /* SInce the active region update requires both activity and visibility,
                         * must find current values of non-updated field just before sending event
                         */
                        case name_Space + "ActiveRegionActivityUpdateType":
                            ActiveRegionStateType currentStateForVisibility = (ActiveRegionStateType)(NameLists.activeRegionNames.ContainedData[((ActiveRegionActivityUpdateType)(events[v])).UnitID]);
                            currentStateForVisibility.IsActive = ((ActiveRegionActivityUpdateType)(events[v])).IsActive;
                            NameLists.activeRegionNames.ContainedData[((ActiveRegionActivityUpdateType)(events[v])).UnitID] = currentStateForVisibility;
                            ActiveRegionUpdateType activityUpdate = new ActiveRegionUpdateType(((ActiveRegionActivityUpdateType)(events[v])).UnitID, ((ActiveRegionActivityUpdateType)(events[v])).Time, currentStateForVisibility);
                            EventCommunicator.SendEvent(activityUpdate);
                            break;

                        case name_Space + "ActiveRegionVisibilityUpdateType":
                            ActiveRegionStateType currentStateForActivity = (ActiveRegionStateType)(NameLists.activeRegionNames.ContainedData[((ActiveRegionVisibilityUpdateType)(events[v])).UnitID]);
                            currentStateForActivity.IsVisible = ((ActiveRegionVisibilityUpdateType)(events[v])).IsVisible;
                            NameLists.activeRegionNames.ContainedData[((ActiveRegionVisibilityUpdateType)(events[v])).UnitID] = currentStateForActivity;
                            ActiveRegionUpdateType visibilityUpdate = new ActiveRegionUpdateType(((ActiveRegionVisibilityUpdateType)(events[v])).UnitID, ((ActiveRegionVisibilityUpdateType)(events[v])).Time, currentStateForActivity);
                            EventCommunicator.SendEvent(visibilityUpdate);
                            break;

                        case name_Space + "CloseChatRoomType":
                            if (ChatRooms.DropChatRoom(((CloseChatRoomType)(events[v])).Room))
                            {
                                EventCommunicator.SendEvent(events[v]);
                            }
                            break;

                        case name_Space + "CloseVoiceChannelType":
                            if (VoiceChannels.DropVoiceChannel(((CloseVoiceChannelType)(events[v])).Channel))
                            {
                                EventCommunicator.SendEvent(events[v]);
                            }
                            break;

                        case name_Space + "Reveal_EventType":
                            UnitFacts.CurrentUnitStates[events[v].UnitID] = ((Reveal_EventType)events[v]).InitialState;
                            EventCommunicator.SendEvent(events[v]);
                            break;

                        case name_Space + "StateChangeEvent":
                            string currentState = UnitFacts.CurrentUnitStates[events[v].UnitID];
                            if (("Dead" != currentState) &&
                                (!((StateChangeEvent)events[v]).IsException(currentState)))
                            {
                                if ((((StateChangeEvent)events[v]).HasPrecursors()) &&
                                    (((StateChangeEvent)events[v]).IsPrecursor(currentState)))
                                {
                                    EventCommunicator.SendEvent(events[v]);
                                }
                                else if (!((StateChangeEvent)events[v]).HasPrecursors())
                                {
                                    EventCommunicator.SendEvent(events[v]);
                                }
                            }
                            break;

                        case name_Space + "TransferEvent":
                            if (UnitFacts.ChangeDM(events[v].UnitID,
                                                   /*   ((TransferEvent)events[v]).From, */ ((TransferEvent)events[v]).To))
                            {
                                EventCommunicator.SendEvent(events[v]);
                            }        // and if not? Throw exception??
                            else
                            {
                                Coordinator.debugLogger.LogError("Timed Queue Manager", "Transfer of Unit " + events[v].UnitID +
                                                                 " from " + ((TransferEvent)events[v]).From + " failed.");
                            }
                            break;

                        case name_Space + "SubplatformLaunchType":
                            SubplatformLaunchType alias     = ((SubplatformLaunchType)events[v]);
                            List <string>         nowDocked = SubplatformRecords.GetDocked(alias.ParentUnit);
                            if (nowDocked.Contains(alias.UnitID))
                            {
                                SubplatformRecords.UnDock(alias.ParentUnit, alias.UnitID);
                                EventCommunicator.SendEvent(events[v]);
                            }
                            break;

                        case name_Space + "SubplatformDockType":
                            SubplatformDockType dock = ((SubplatformDockType)events[v]);
                            string adopterID         = dock.ParentUnit;

                            if (SubplatformRecords.CountDockedOfSpecies(adopterID, UnitFacts.GetSpecies(dock.UnitID)) <= SpeciesType.GetSpecies(UnitFacts.GetSpecies(adopterID)).GetSubplatformCapacity(UnitFacts.GetSpecies(dock.UnitID)))
                            {
                                if (SubplatformRecords.RecordDocking(thisTarget, dock.UnitID) == true)
                                {
                                    EventCommunicator.SendEvent(events[v]);
                                }
                                else
                                {
                                    string someError = "This failed because the subplatform wasn't able to be docked to this platform";
                                }
                            }
                            break;

                        //SubplatformLaunchType is a response to a launch request,
                        //LaunchEventType was intended to be from the scenario. This needs to be rethought.
                        case name_Space + "LaunchEventType":
                            // Note -- it isn't an error if the thing isn't docked any more

                            LaunchEventType launch = (LaunchEventType)events[v];
                            // This comes from scenario so we only check if there is something to launch
                            if ("" != launch.Child)
                            {
                                List <string> dockedNow = SubplatformRecords.GetDocked(launch.UnitID);
                                if (dockedNow.Contains(launch.Child))
                                {
                                    SubplatformRecords.UnDock(launch.UnitID, launch.Child);

                                    ///???        Subplatforms.GetDocked(launch.UnitID);
                                    // not in sim model      launch.Genus = Genealogy.GetGenus(launch.Child);
                                    SubplatformRecords.UnDock(launch.UnitID, launch.Child);
                                    EventCommunicator.SendEvent(launch);
                                }
                            }

                            break;

                        case name_Space + "WeaponLaunchEventType":
                            // Note -- it isn't an error if the thing isn't docked any more

                            WeaponLaunchEventType launchWeapon = (WeaponLaunchEventType)events[v];
                            // This comes from scenario so we only check if there is something to launch
                            if ("" != launchWeapon.Child)
                            {
                                List <string> dockedNow = SubplatformRecords.GetDocked(launchWeapon.UnitID);
                                if (dockedNow.Contains(launchWeapon.Child))
                                {
                                    SubplatformRecords.UnDock(launchWeapon.UnitID, launchWeapon.Child);
                                    SubplatformRecords.UnDock(launchWeapon.UnitID, launchWeapon.Child);
                                    EventCommunicator.SendEvent(launchWeapon);
                                }
                            }

                            break;

                        case name_Space + "EngramSettingType":
                            //This is the inital value so it was set in the table at parset time
                            EventCommunicator.SendEvent(events[v]);
                            break;

                        case name_Space + "ChangeEngramType":
                            ChangeEngramType newValue = ((ChangeEngramType)events[v]);
                            Engrams.Set(newValue.Name, newValue.UnitID, newValue.EngramValue);
                            EventCommunicator.SendEvent(new EngramSettingType(newValue.Name, newValue.UnitID, newValue.EngramValue, Engrams.GetType(newValue.Name)));
                            break;

                        case name_Space + "RemoveEngramEvent":
                            Engrams.Remove(((RemoveEngramEvent)events[v]).Name);
                            break;

                        case name_Space + "OpenChatRoomType":
                            //Requests from below are handled by EventCommunicator
                            //This processing is for commands in script -- ??
                            string           chatFailureMessage = "";
                            OpenChatRoomType ocr = ((OpenChatRoomType)events[v]);
                            if (("EXP" != ocr.Owner) && !UnitFacts.IsDM(ocr.Owner))
                            {
                                chatFailureMessage = "The name '" + ocr.Owner + "' is not a valid decision maker.";
                            }
                            else
                            {
                                for (int i = 0; i < ocr.Members.Count; i++)
                                {
                                    DecisionMakerType DMi = DecisionMakerType.GetDM(ocr.Members[i]);
                                    for (int mbr = 1 + i; mbr < ocr.Members.Count; mbr++)
                                    {
                                        if (!DMi.CanChatWith(ocr.Members[mbr]))
                                        {
                                            chatFailureMessage = "Decison Makers '" + DMi.Identifier + "' cannot be in a chat room with '" + ocr.Members[mbr] + "'";
                                            break;
                                        }
                                        if ("" != chatFailureMessage)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                            if ("" == chatFailureMessage)
                            {
                                chatFailureMessage = ChatRooms.AddRoom(ocr);
                                EventCommunicator.SendEvent(ocr);
                            }
                            if ("" != chatFailureMessage)
                            {
                                // DON'T throw new ApplicationException("Could not create chatroom '"+ocr.Range+"': "+chatFailureMessage);
                                // send a system message instead
                            }
                            break;

                        case name_Space + "SendChatMessageType":
                            // Script induced. Only need to check if there is such a room
                            if (ChatRooms.IsRoom(((SendChatMessageType)(events[v])).RoomName))
                            {
                                EventCommunicator.SendEvent(events[v]);
                            }
                            break;

                        case name_Space + "OpenWhiteboardRoomType":
                            //Requests from below are handled by EventCommunicator
                            //This processing is for commands in script -- ??
                            string whiteboardFailureMessage = "";
                            OpenWhiteboardRoomType owr      = ((OpenWhiteboardRoomType)events[v]);
                            if (("EXP" != owr.Owner) && !UnitFacts.IsDM(owr.Owner))
                            {
                                whiteboardFailureMessage = "The name '" + owr.Owner + "' is not a valid decision maker.";
                            }
                            else
                            {
                                for (int i = 0; i < owr.Members.Count; i++)
                                {
                                    DecisionMakerType DMi = DecisionMakerType.GetDM(owr.Members[i]);
                                    for (int mbr = 1 + i; mbr < owr.Members.Count; mbr++)
                                    {
                                        if (!DMi.CanWhiteboardWith(owr.Members[mbr]))
                                        {
                                            whiteboardFailureMessage = "Decison Makers '" + DMi.Identifier + "' cannot be in a whiteboard room with '" + owr.Members[mbr] + "'";
                                            break;
                                        }
                                        if ("" != whiteboardFailureMessage)
                                        {
                                            break;
                                        }
                                    }
                                }
                            }
                            if ("" == whiteboardFailureMessage)
                            {
                                whiteboardFailureMessage = WhiteboardRooms.AddRoom(owr);
                            }
                            if ("" != whiteboardFailureMessage)
                            {
                                // DON'T throw new ApplicationException("Could not create whiteboardroom '"+owr.Range+"': "+whiteboardFailureMessage);
                                // send a system message instead
                            }
                            break;

                        case name_Space + "OpenVoiceChannelType":
                            //Requests from below would be/are handled by EventCommunicator
                            //This processing is for commands in script -- ??
                            string voiceFailureMessage = "";
                            OpenVoiceChannelType ovct  = ((OpenVoiceChannelType)events[v]);
                            //if (("EXP" != ovct.Owner) && !UnitFacts.IsDM(ovct.Owner))
                            //{
                            //    voiceFailureMessage = "Open Voice Channel: The name '" + ovct.Owner + "' is not a valid decision maker.";
                            //    ErrorLog.Write(voiceFailureMessage);
                            //}
                            //else
                            //{
                            voiceFailureMessage = VoiceChannels.AddChannel(ovct);
                            if ("" != voiceFailureMessage)
                            {
                                ErrorLog.Write(voiceFailureMessage);
                            }
                            else
                            {
                                //ovct.InitialMembers = DecisionMakerType.GetVoiceChannelMembers(ovct.Channel); //TODO: AD: Is this even NECESSARY?
                                EventCommunicator.SendEvent(ovct);
                            }
                            //}
                            break;

                        case name_Space + "FlushEvents":
                            //first drop all timer events involving this unit
                            TimerQueueClass.FlushOneUnit(((FlushEvents)events[v]).UnitID);
                            // Then all events on happenin queue about this unit
                            for (int h = 0; h < HappeningList.Happenings.Count; h++)
                            {    // Find first happening event that keys off this state change
                                HappeningCompletionType incident = HappeningList.Happenings[h];
                                if (incident.UnitID == ((FlushEvents)events[v]).UnitID)
                                {
                                    HappeningList.Happenings.RemoveAt(h);
                                }
                                else     //  examine all the DoThisLists
                                {
                                    List <int> removals = new List <int>();
                                    for (int d = 0; d < incident.DoThisList.Count; d++)
                                    {
                                        if (incident.DoThisList[d].Involves(((FlushEvents)events[v]).UnitID))
                                        {
                                            removals.Add(d);
                                        }
                                        //then remove from back to front to preserve indices
                                        for (int r = removals.Count - 1; r >= 0; r--)
                                        {
                                            incident.DoThisList.RemoveAt(r);
                                        }
                                    }
                                }
                            }
                            break;

                        case name_Space + "ForkReplayEventType":
                            EventCommunicator.SendEvent(events[v]);
                            break;

                        default:
                            EventCommunicator.SendEvent(events[v]);
                            break;
                        }
                    }
                }
                TimerQueueClass.DropNode(time);
            }
        }
Example #30
0
 public IChatRoom GetChatRoomByID(Guid chatRoomId)
 {
     return(ChatRooms.FirstOrDefault(i => i.ChatRoomID == chatRoomId));
 }
Example #31
0
        public async Task <bool> Add(ChatRooms rooms)
        {
            await _ctx.ChatRooms.AddAsync(rooms);

            return(await SaveAsync());
        }