Пример #1
0
        public bool ExecuteConditionalAction()
        {
            LOG(LogLevel.VERBOSE, $"Forward to other users: {messageBroker.ChatRoom.ChatUserList.Count - 1}");

            var router = (RouterSocket)messageBroker.Socket;

            messageBroker.Server_BroadcastMessage(messageBroker.ChatRoom.ChatUserList, router, rawAddress, userChatMessage);
            return(true);
        }
        public bool ExecuteConditionalAction()
        {
            // validating exit (to broadcast)
            if (chatMessage.Validate(validExit).IsValid)
            {
                UserSession chatUserReg = new UserSession(rawAddress.Replace("\0", ""));
                var         router      = (RouterSocket)messageBroker.Socket;

                var msgBroadcastExit = ChatMessageFactory.CreateDefault(Command.BROADCAST_END_SESSION, Participant.SERVER, chatUserReg);

                messageBroker.Server_BroadcastMessage(messageBroker.ChatRoom.ChatUserList, router, rawAddress, msgBroadcastExit);

                return(true);
            }

            return(false);
        }
        public bool ExecuteConditionalAction()
        {
            // New user registration
            if (chatMessage.Validate(_validRegistration).IsValid)
            {
                UserSession chatUserReg = new UserSession(rawAddress.Replace("\0", ""));
                int         ix          = messageBroker.ChatRoom.ChatUserList.IndexOf(rawAddress);
                chatUserReg.SetUserName($"{chatMessage.UserName}{ix}");

                var msgResponseRegistration = ChatMessageFactory.CreateDefault(Command.REQ_REGISTER_USERNAME, Participant.SERVER, chatUserReg);

                var router = (RouterSocket)messageBroker.Socket;

                messageBroker.Server_SendReply(router, new NetMQFrame(rawAddress), msgResponseRegistration);

                var msgBroadcastNewUser = ChatMessageFactory.CreateDefault(Command.BROADCAST_NEW_USER, Participant.SERVER, chatUserReg);

                messageBroker.Server_BroadcastMessage(messageBroker.ChatRoom.ChatUserList, router, rawAddress, msgBroadcastNewUser);

                return(true);
            }

            return(false);
        }