public override void Execute()
        {
            User user = UserRepository.Instance.FindUserByClientKey(_clientId);

            if (user != null)
            {
                List <User> userList = new List <User>();
                if (string.IsNullOrEmpty(_room))
                {
                    userList = UserRepository.Instance.FindUsersByRoom(user.Room);
                }
                else
                {
                    userList = UserRepository.Instance.FindUsersByRoom(_room);
                }

                var query = from u in userList
                            select new ServerUser()
                {
                    Name = u.UserName
                };

                MSMQQueueWrapper.QueueCommand(
                    new SendObjectCommand(_clientId,
                                          new ListUsersInRoomResponse()
                {
                    Users = query.ToArray()
                })
                    );
            }
        }
        public override bool HandleRequest(GetCentralAuthorityRequest request, Guid state)
        {
            MSMQQueueWrapper.QueueCommand(
                new GetCentralAuthorityCommand(state)
                );

            return(true);
        }
Beispiel #3
0
        public override bool HandleRequest(ListUsersInRoomRequest request, Guid state)
        {
            MSMQQueueWrapper.QueueCommand(
                new ListUsersInRoomCommand(request.RoomName, state)
                );

            return(true);
        }
Beispiel #4
0
 public void HandleRequest(DeleteRoomVariableRequest request, Guid state)
 {
     if (request != null)
     {
         MSMQQueueWrapper.QueueCommand(
             new DeleteRoomVariableCommand(state, request.ZoneId, request.RoomId, request.Name)
             );
     }
 }
Beispiel #5
0
 public void HandleRequest(GetKeyParametersRequest request, Guid state)
 {
     if (request != null)
     {
         MSMQQueueWrapper.QueueCommand(
             new GetKeyParametersCommand(state)
             );
     }
 }
        public void HandleRequest(CreateRoomRequest request, Guid state)
        {
            if (request != null)
            {
                string roomName = request.RoomName;

                MSMQQueueWrapper.QueueCommand(
                    new CreateRoomCommand(state, request.ZoneName, roomName)
                    );
            }
        }
        public void HandleRequest(PublicMessageRequest request, Guid state)
        {
            var user = UserRepository.Instance.Query(u => u.ClientKey.Equals(state)).FirstOrDefault();

            if (user != null)
            {
                MSMQQueueWrapper.QueueCommand(
                    new PublicMessageCommand(request.ZoneId, request.RoomId, user.Name, request.Message)
                    );
            }
        }
Beispiel #8
0
        public void HandleRequest(NegotiateKeysRequest request, Guid state)
        {
            if (request != null)
            {
                MSMQQueueWrapper.QueueCommand(
                    new NegotiateKeysCommand(state)
                    );

                //return true;
            }

            //return false;
        }
Beispiel #9
0
        //protected virtual void OnClientRequestReceived(Guid clientId, RequestHeader header, object request)
        //{
        //    EventHandler<ClientRequestEventArgs> clientRequestReceived = ClientRequestReceived;
        //    if (clientRequestReceived != null)
        //    {
        //        var args = new ClientRequestEventArgs(clientId, header, request);
        //        clientRequestReceived(this, args);
        //    }
        //}

        /// <summary>
        /// Starts the server.
        /// </summary>
        public void StartServer()
        {
            SocketServerConfiguration configuration = null;

            try
            {
                configuration = ServerConfigurationHelper.GetServerConfiguration();
            }
            catch (Exception exception)
            {
                Logger.Error(exception.ToString());
            }

            if (configuration != null)
            {
                MSMQQueueWrapper.QueueCommand(new ServerStartingCommand());

                _socketServer.StartServer(configuration.ListenPort);

                Logger.InfoFormat("Server started and listening on {0}", configuration.ListenPort);
            }
        }
Beispiel #10
0
 protected void SocketServerClientDisconnecting(object sender, DisconnectedArgs e)
 {
     MSMQQueueWrapper.QueueCommand(new LogoutUserCommand(e.ClientId));
 }
Beispiel #11
0
 public void HandleRequest(CreateRoomVariableRequest request, Guid state)
 {
     MSMQQueueWrapper.QueueCommand(
         new CreateRoomVariableCommand(state, request.ZoneId, request.RoomId, request.Name, request.Value)
         );
 }