Пример #1
0
        public FeedbackCore(bool verboseOutput, ServerCore serverCore, MainWindow thisParent = null)
        {
            isVerbose = verboseOutput;
            server = serverCore;

            if (thisParent != null)
            {
                isGUI = true;
                parent = thisParent;
            }
        }
        /// <summary>
        /// Create a new instance of the context that attaches to the specified directory location
        /// </summary>
        /// <param name="connectionString">The Brightstar service connection string</param>
        /// <remarks>The data context is thread-safe but doesn't support concurrent access to the same base location by multiple
        /// instances. You should ensure in your code that only one EmbeddedDataObjectContext instance is connected to any given base location
        /// at a given time.</remarks>
        public EmbeddedDataObjectContext(ConnectionString connectionString)
        {
            if (connectionString == null)
            {
                throw new ArgumentNullException("connectionString");
            }
            if (connectionString.Type != ConnectionType.Embedded)
            {
                throw new ArgumentException("Invalid connection type", "connectionString");
            }

            _serverCore = ServerCoreManager.GetServerCore(connectionString.StoresDirectory);
            _optimisticLockingEnabled = connectionString.OptimisticLocking;
        }
Пример #3
0
        /* The GetAllDomainsOrdered MessageHandler
         * It handles messages of GET_ALL_DOMAINS_ORDERED_REQUEST type.
         */
        private static void GetAllDomainsOrdered(RMessage message, TcpClient connection)
        {
            uint uid = ServerCore.GetIdByConnection(connection);
            List <DomainData> validations    = DomainConnector.GetUserValidations(uid);
            List <DomainData> nonValidations = DomainConnector.GetUserNonValidations(uid);

            validations.AddRange(nonValidations);
            RMessage replyMessage =
                new RMessage(
                    MessageType.GET_ALL_DOMAINS_ORDERED_REPLY,
                    validations);

            ServerCore.GetWorkerByConnection(connection).SendMessage(replyMessage);
        }
Пример #4
0
        /* The GetFriendList MessageHandler
         * It handles messages of ADD_SAY_REQUEST type.
         */
        private static void AddSay(RMessage message, TcpClient connection)
        {
            Console.WriteLine("AddSay");
            SayData say = (SayData)(message.Data);
            uint    id  = say.Id;

            say.Id = ServerCore.GetIdByConnection(connection);
            if (ServerCore.GetWorkerById(id) != null)
            {
                RMessage replyMessage = new RMessage(MessageType.ADD_SAY_REPLY, say);
                ServerCore.GetWorkerById(id).SendMessage(replyMessage);
            }
            UserConnector.UpdateUserRank(say.Id, Ranking.ADD_SAY);
        }
Пример #5
0
        private void GenerateKeyExecuteCommand()
        {
            var serverCore    = new ServerCore();
            var modelKeyQuery = serverCore.GetLicenseKeyQueryModelByKeyQuery(KeyQuery);

            ComputerName = modelKeyQuery.ComputerName;
            ProductName  = modelKeyQuery.ProductName;
            ProcessorId  = modelKeyQuery.ProcessorId;
            SerialOs     = modelKeyQuery.SystemSerial;

            var key = serverCore.GenerateKeyByKeyQueryBase64Url(KeyQuery);

            Key = key;
        }
Пример #6
0
        /// <summary>
        /// Only call this method on an another thread
        /// Starts the thread running the match
        /// </summary>
        public void ThreadStart()
        {
            var DBHandler = new DBMessageHandler(logger, this);

            server = new ServerCore(DBHandler, ServerConnectionInfo.DBConnectionInfo(), logger);
            DBHandler.Init(server);
            logger.Log("Database setup and running");

            while (true)
            {
                server.Update();
                System.Threading.Thread.Sleep(miliSecondPerTick);
            }
        }
Пример #7
0
        public EntitySpawningManager(ServerCore server, IEntitySpawningControler entitySpawningControler)
        {
            _server = server;
            _entitySpawningControler = entitySpawningControler;
            _configuration           = _server.WorldParameters.Configuration as UtopiaWorldConfiguration;
            _landscapeManager        = server.LandscapeManager;
            _fastRandom = new FastRandom();

            //This spawn logic can only be down on UtopiaWorldConfiguration and associated processor.
            if (_configuration != null)
            {
                _server.Clock.CreateNewTimer(new Clock.GameClockTimer(UtopiaTimeSpan.FromMinutes(30), server.Clock, UtopiaSpawningLookup));
            }
        }
Пример #8
0
        private static void SignOut(RMessage message, TcpClient connection)
        {
            Console.WriteLine("SignOut");
            UserData user = (UserData)message.Data;

            Console.WriteLine("SignOut Succeeded.");
            ServerCore.RemoveIdConnectionMapping(user.Id, connection);
            RMessage replyMessage =
                new RMessage(
                    MessageType.SIGN_OUT_REPLY,
                    user);

            ServerCore.GetWorkerByConnection(connection).SendMessage(replyMessage);
        }
Пример #9
0
        /* The GetUserInfo MessageHandler
         * It handles messages of GET_USER_INFO_REQUEST type.
         */
        private static void GetUserInfo(RMessage message, TcpClient connection)
        {
            UserData user = (UserData)message.Data;

            user = UserConnector.GetUserById(user.Id);
            List <Object> list = new List <Object>();

            list.Add(user);
            list.Add(DomainConnector.GetAllDomains());             // all domains
            list.Add(DomainConnector.GetUserValidations(user.Id)); // domains for which the user has certificates
            RMessage replyMessage = new RMessage(MessageType.GET_USER_INFO_REPLY, list);

            ServerCore.GetWorkerByConnection(connection).SendMessage(replyMessage);
        }
Пример #10
0
 public void Initialize(ServerCore server)
 {
     playerToScore = new Dictionary <Server_ServerClient, PlayerScore>();
     scores        = new List <PlayerScore>();
     for (int i = 0; i < server.clientManager.GetClients().Count; i++)
     {
         var score = new PlayerScore()
         {
             guid      = server.clientManager.GetClients()[i].info.GUID,
             roundsWon = 0
         };
         playerToScore.Add(server.clientManager.GetClients()[i], score);
         scores.Add(score);
     }
 }
Пример #11
0
        /* The EditResource MessageHandler
         * It handles messages of EDIT_RESOURCE_REQUEST type.
         */
        private static void EditResource(RMessage message, TcpClient connection)
        {
            Console.WriteLine("EditResource");
            ResourceData res = (ResourceData)message.Data;

            ResourceConnector.EditResource(res);
            ResourceData        editedResource = ResourceConnector.GetResource(res.Id);
            RMessage            replyMessage   = new RMessage(MessageType.EDIT_RESOURCE_REPLY, editedResource);
            List <ClientWorker> clientList     = ServerCore.GetAllWorkers();

            foreach (ClientWorker client in clientList)
            {
                client.SendMessage(replyMessage);
            }
        }
Пример #12
0
        /* The CheckResourceVote MessageHandler
         * It handles messages of RANK_CHECK_RESOURCE_VOTE_REQUEST type.
         */
        private static void CheckResourceVote(RMessage message, TcpClient connection)
        {
            Console.WriteLine("CheckResourceVote");
            UserData         usr          = (UserData)(((List <Object>)message.Data)[0]);
            ResourceData     res          = (ResourceData)(((List <Object>)message.Data)[1]);
            ResourceVoteData resVote      = ResourceVoteConnector.CheckResourceVote(usr, res);
            List <Object>    replyContent = new List <Object>();

            replyContent.Add(usr);
            replyContent.Add(res);
            replyContent.Add(resVote);
            RMessage replyMessage = new RMessage(MessageType.RANK_CHECK_RESOURCE_VOTE_REPLY, replyContent);

            ServerCore.GetWorkerByConnection(connection).SendMessage(replyMessage);
        }
Пример #13
0
        public void Dispose()
        {
            if (Server != null)
            {
                Server.LoginManager.PlayerEntityNeeded -= LoginManagerPlayerEntityNeeded;

                Server.Dispose();
                _server = null;
            }
            if (_serverSqliteStorageSinglePlayer != null)
            {
                _serverSqliteStorageSinglePlayer.Dispose();
                _serverSqliteStorageSinglePlayer = null;
            }
        }
Пример #14
0
        public VoiceRecogCore(ServerCore vrpnServer, bool verboseOutput, MainWindow thisParent = null)
        {
            server = vrpnServer;
            verbose = verboseOutput;
            if (server == null)
            {
                throw new Exception("The VRPN server does not exist!");
            }

            parent = thisParent;
            if (parent != null)
            {
                isGUI = true;
            }
        }
Пример #15
0
        public void Execute(ServerCore server, ClientConnection connection, string[] arguments)
        {
            if (connection.SelectedNpc == null)
            {
                connection.SendChat("No npc is selected");
                return;
            }

            try
            {
                ServerDynamicEntity serverEntity;

                if (!server.AreaManager.TryFind(connection.SelectedNpc.DynamicId, out serverEntity))
                {
                    connection.SendChat("Can't find the server entity");
                    return;
                }

                var serverNpc = serverEntity as ServerNpc;

                if (serverNpc == null)
                {
                    connection.SendChat("Invalid type of the server entity");
                    return;
                }

                var humanAi = serverNpc.GeneralAI as HumanAI;

                if (humanAi == null)
                {
                    connection.SendChat("Invalid type of the AI");
                    return;
                }

                humanAi.CurrentActivity.KeyPoints.Add(new KeyPoint()
                {
                    Position     = connection.ServerEntity.DynamicEntity.Position.ToCubePosition(),
                    HeadRotation = connection.ServerEntity.DynamicEntity.HeadRotation
                });
                serverNpc.Character.OnNeedSave();

                connection.SendChat("New key point was added");
            }
            catch (Exception x)
            {
                connection.SendChat("Error: " + x);
            }
        }
Пример #16
0
        /*
         * On connection crash, makes the user offline
         */
        private static void MakeUserOffline(TcpClient connection)
        {
            uint            id           = ServerCore.GetIdByConnection(connection);
            UserData        user         = UserConnector.UpdateUserState(id, false);
            List <UserData> friendList   = UserConnector.GetFriendList(id);
            RMessage        replyMessage = new RMessage(MessageType.CHANGE_USER_STATE_REPLY, user);

            foreach (UserData friend in friendList)
            {
                ClientWorker worker = ServerCore.GetWorkerById(friend.Id);
                if (worker != null)
                {
                    ServerCore.GetWorkerById(friend.Id).SendMessage(replyMessage);
                }
            }
        }
Пример #17
0
        /* The PostResource MessageHandler
         * It handles messages of ADD_RESOURCE_REQUEST type.
         */
        private static void PostResource(RMessage message, TcpClient connection)
        {
            Console.WriteLine("PostResource");
            ResourceConnector.AddResource((ResourceData)message.Data);
            // a lil' something for the user
            UserConnector.UpdateUserRank(ServerCore.GetIdByConnection(connection), Ranking.USER_POSTED_RESOURCE_VALUE);

            ResourceData        adddedResource = ResourceConnector.GetResource((ResourceData)message.Data);
            RMessage            replyMessage   = new RMessage(MessageType.ADD_RESOURCE_REPLY, adddedResource);
            List <ClientWorker> clientList     = ServerCore.GetAllWorkers();

            foreach (ClientWorker client in clientList)
            {
                client.SendMessage(replyMessage);
            }
        }
        public bool IsChecker(IPAddress ip)
        {
            if (!this.IsTesting)
            {
                return(false);
            }

            if (this.checking_me.Find(x => x.Equals(ip)) != null)
            {
                this.IsTesting = false;
                this.checking_me.Clear();
                ServerCore.Log("TCP firewall test succeeded");
                return(true);
            }

            return(false);
        }
Пример #19
0
        /// <summary>
        /// Initialized the global <see cref="CoflnetCore.Instance"/> as a `devCore`.
        /// Will reset the development enviroment when called again (to support multiple unit tests)
        /// </summary>
        /// <param name="id">Application/Server Id to use</param>
        /// <param name="preventDefaultScreens"><c>true</c> when default settings (dummys) should NOT be set such as <see cref="DummyPrivacyScreen"/></param>
        /// <param name="preventInit"><c>true</c> when The Inits of Client and Server-Cores should not be invoked and client should be prepared like a fresh install</param>
        public static void Init(EntityId id, bool preventDefaultScreens = false, bool preventInit = false)
        {
            //[Deprecated]
            ConfigController.ActiveUserId = id;
            // sets the primary managing server
            ConfigController.ApplicationSettings.id = id.FullServerId;

            if (!preventDefaultScreens)
            {
                SetupDefaults();
            }

            // to have instances loaded
            var toLoadInstance = ClientCore.ClientInstance;
            var serverInstance = ServerCore.ServerInstance;

            if (DevInstance == null)
            {
                DevInstance = new DevCore();
                DevInstance.simulationInstances = new Dictionary <EntityId, SimulationInstance> ();
                CoflnetCore.Instance            = DevInstance;
            }
            else
            {
                // reset if there was an devinstance bevore
                DevInstance.simulationInstances.Clear();
                ServerCore.ServerInstance = new ServerCoreProxy();
                ClientCore.ClientInstance = new ClientCoreProxy();
            }

            DevInstance.AddServerCore(id.FullServerId);
            if (!id.IsServer)
            {
                DevInstance.AddClientCore(id);
            }
            else
            {
                DevInstance.AddClientCore(EntityId.Default);
            }

            if (!preventInit)
            {
                ServerCore.Init();
                ClientCore.Init();
            }
        }
Пример #20
0
        public Server(Dictionary <TypeOfDialog, Dictionary <int, Se_AuthDialog> > p_auth_dialogs
                      , ref Dictionary <TypeOfDialog, Dictionary <int, Se_UnAuthDialog> > p_unauth_dialogs, Dictionary <int, PrivateChat> p_all_private_chats
                      , Dictionary <int, PublicChat> p_all_public_chats, ref Dictionary <int, AddAgreement> p_all_add_agreements, Dictionary <int, UserData> p_all_users_logged_in,
                      List <int> p_all_threads, SendToDistributerConstruct p_send_to_distributer_construct, object p_distributer_pulse_object)
        {
            Se_ServerDelegateForDialogs server_delegates_for_dialogs = new Se_ServerDelegateForDialogs(new GetFriendsList(Se_GetUserfriendList), new GetUserStatus(Se_GetUserStatus)
                                                                                                       , new GetPublicChatIds(Se_GetPublicChatIds), new GetOfflineMessages(Se_GetAllUserOfflineMessages), new GetAllAgreementInvitation(Se_GetAllUserAgreementInvitation)
                                                                                                       , new AuthSend(Se_Authsend), new IsLoggedIn(Se_IsLoggedIn), new UnAuthSend(Se_UnAuthSend), new IsThereUnauthWorkerThread(Se_IsThereUnauthWorkerThread)
                                                                                                       , new Login(Se_Login), new ServerInformChatLeave(Se_ServerInformChatLeave), new OnlineAreFriends(Se_OnlineAreFriends), new CreatePrivateChat(Se_CreatePrivateChat)
                                                                                                       , new IsTherePrivateChat(Se_IsTherePrivateChat), new StartClientCreatedPrivateChatInform(Se_StartClientCreatedPrivateChatInform)
                                                                                                       , new JoinPublicChatRequest(Se_JoinPublicChatRequest), new IsUserInPublicChat(Se_IsUserInPublicChat), new GetPublicChatUsersList(Se_GetPublicChatUsersList)
                                                                                                       , new CreateFormalMessageRequest(Se_CreateFormalMessageRequest), new IstherUser(Se_IstherUser), new CreateOfflineMessage(Se_CreateOfflineMessage)
                                                                                                       , new SignUp(Se_Signup), new CreateAddAgreement(Se_CreateAddAgreement), new GetAgreementAnswer(Se_GetAgreementAnswer), new OfflineMessagesReadInform(Se_OfflineMessagesReadInform)
                                                                                                       , new GetPrivateChatInvitationAnswer(Se_GetPrivateChaInvitationAnswer), new GetAUserAgreementInvitation(Se_DB_GetAUserAgreementInvitation));

            server_core = new ServerCore(p_all_users_logged_in, new StartClientFriendChangedStatusInformDialog(Se_StartClientFriendChangedStatusInform)
                                         , new StartSendToClinetFormalMessage(Se_StartSendToClinetFormalMessage), p_all_threads, p_send_to_distributer_construct, p_distributer_pulse_object);

            all_dialogs = new AllDialogs(server_delegates_for_dialogs, ref p_auth_dialogs, ref p_unauth_dialogs);


            all_chats = new AllChats(p_all_private_chats, p_all_public_chats,
                                     new ChatSend(Se_ChatSend), new StartEjectedChatUserInform(Se_StartEjectedChatUserInform), new IsLoggedIn(Se_IsLoggedIn),
                                     new StartClientSomeoneJoinedChatInform(Se_StartClientSomeoneJoinedChatInform), new StartClientSomeoneLeftChatInform(Se_StartClientSomeoneLeftChatInform));

            all_agreements = new AllAgreements(ref p_all_add_agreements, new CreateFormalMessageRequest(Se_CreateFormalMessageRequest), new DB_IsThereUser(Se_IstherUser)
                                               , new DB_AddToFriends(Se_AddToFriends), new DB_AreFriends(Se_AreFriends), new DB_CreateAddAgreement(Se_DB_CreateAddAgreement), new DB_RemoveAgreement(Se_RemoveAgreement)
                                               , new IsLoggedIn(Se_IsLoggedIn), new StartClientFriendListChangedInformDialog(Se_StartClientFriendListChangedInformDialog), new ReloadFriendList(Se_ReloadFriendList)
                                               , new GetOnlineUserFriendList(Se_GetOnlineUserFriendList), new GetUserStatus(Se_GetUserStatus), new AddAgreementDone(Se_AddAgreementDone)
                                               , new GetAllAdAgreements(Se_GetAllAdAgreements), new StartClientInvitedAgreementInform(Se_StartClientInvitedAgreementInform));


            thread_works = new ThreadWorks(new RegisterThread(Se_RegisterThread), new IsThereUnauthWorkerThread(Se_IsThereUnauthWorkerThread)
                                           , new RemoveThread(Se_RemoveThread), new RemoveAThreadDialogs(Se_RemoveAThreadDialogs));


            offline_user_works = new OfflineUserWorks(new ChangeStatusToOffline(Se_ChangeStatusToOffline), new OfflineUser(Se_OfflineUser), new GetUserPresenceState(Se_GetUserPresenceState)
                                                      , new GetOnlineUserThreadID(Se_GetOnlineUserThreadID), new UserLeaveAllChats(Se_UserLeavAllChats), new RemoveAThreadDialogs(Se_RemoveAThreadDialogs)
                                                      , new RemoveAUserDialogs(Se_RemoveAUserDialogs), new RemoveThread(Se_RemoveThread));


            authenicate_and_distribute = new AuthenticateAndDistribute(new GetAThreadUserName(Se_GetAThreadUserName), new IsThereUnauthWorkerThread(Se_IsThereUnauthWorkerThread)
                                                                       , new DialogReceiveMessage(Se_DialogReceiveMessage), new ChatReceiveMessage(Se_ChatReceiveMessage), new MakeMessagesOffline(Se_MakeMessagesOffline)
                                                                       , new UserOfflineRequest(Se_UserOfflineRequest), new ThreadisLoggedIn(Se_ThreadIsLoggedIn), new RegisterAThreadRequest(Se_RegisterAThreadRequest)
                                                                       , new ThreadRemoveWorks(Se_ThreadRemoveWorks));
        }
Пример #21
0
        /* The GetFriendList MessageHandler
         * It handles messages of ADD_FRIEND_REQ type.
         */
        private static void AddFriend(RMessage message, TcpClient connection)
        {
            Console.WriteLine("AddFriend");
            uint     thisUserId = ServerCore.GetIdByConnection(connection);
            UserData friend     = UserConnector.GetUser((String)message.Data);
            UserData thisUser   = UserConnector.GetUser(thisUserId);

            if (friend == null)
            {
                return;
            }
            if (friend.Id == thisUserId)
            {
                return;
            }
            List <FriendshipData> friendships = FriendshipConnector.GetFriendshipList(thisUserId);

            foreach (FriendshipData friendshipIt in friendships)
            {
                if (friendshipIt.Former == friend.Id || friendshipIt.Latter == friend.Id)
                {
                    return;
                }
            }
            FriendshipData friendship = new FriendshipData(thisUserId, friend.Id, false);

            FriendshipConnector.AddFriendship(friendship);

            ClientWorker formerWorker = ServerCore.GetWorkerById(friendship.Former);
            ClientWorker latterWorker = ServerCore.GetWorkerById(friendship.Latter);

            RMessage replyMessageFormer = new RMessage(MessageType.ADD_FRIEND_REPLY, friend);
            RMessage replyMessageLatter = new RMessage(MessageType.ADD_FRIEND_REPLY, thisUser);
            RMessage replyMessage       = new RMessage(MessageType.ADD_FRIENDSHIP_REPLY, friendship);

            if (formerWorker != null)
            {
                formerWorker.SendMessage(replyMessageFormer);
                formerWorker.SendMessage(replyMessage);
            }
            if (latterWorker != null)
            {
                latterWorker.SendMessage(replyMessageLatter);
                latterWorker.SendMessage(replyMessage);
            }
        }
Пример #22
0
        /* The AddReference MessageHandler
         * It handles messages of ADD_REFERENCE_REQUEST type.
         */
        private static void AddReference(RMessage message, TcpClient connection)
        {
            Console.WriteLine("AddReference");
            List <UInt32> ids = (List <UInt32>)message.Data;

            QuestionConnector.AddReference(ids);

            RMessage replyMessage = new RMessage(MessageType.ADD_QUESTION_REFERENCE_REPLY, null);
            //ServerCore.GetWorkerByConnection(connection).SendMessage(replyMessage);

            List <ClientWorker> allWorkers = ServerCore.GetAllWorkers();

            foreach (ClientWorker workersIterator in allWorkers)
            {
                workersIterator.SendMessage(replyMessage);
            }
        }
Пример #23
0
        /* The UserTakenCheck MessageHandler
         * It handles messages of USERNAME_TAKEN_REQUEST type.
         */
        private static void UserTakenCheck(RMessage message, TcpClient connection)
        {
            Console.WriteLine("UserTakenCheck request");
            UserData user  = (UserData)message.Data;
            Boolean  taken = false;

            if (user != null)
            {
                taken = (UserConnector.GetUser(user.Username) != null);
            }
            RMessage replyMessage =
                new RMessage(
                    MessageType.USERNAME_TAKEN_REPLY,
                    taken);

            ServerCore.GetWorkerByConnection(connection).SendMessage(replyMessage);
        }
Пример #24
0
        /* The ResourceAccess MessageHandler
         * It handles messages of RANK_RESOURCE_ACCESSED_REQUEST type.
         */
        private static void ResourceAccess(RMessage message, TcpClient connection)
        {
            Console.WriteLine("AccessResource");
            ResourceData res = (ResourceData)message.Data;

            ResourceConnector.UpdateResourceRank(res, Ranking.RESOURCE_ACCESSED_VALUE);

            ResourceData editedResource = ResourceConnector.GetResource(res.Id);

            RMessage            replyMessage = new RMessage(MessageType.EDIT_RESOURCE_REPLY, editedResource);
            List <ClientWorker> clientList   = ServerCore.GetAllWorkers();

            foreach (ClientWorker client in clientList)
            {
                client.SendMessage(replyMessage);
            }
        }
Пример #25
0
        /* The GetFriendList MessageHandler
         * It handles messages of CHANGE_USER_STATE_REQUEST type.
         */
        private static void ChangeUserState(RMessage message, TcpClient connection)
        {
            Console.WriteLine("ChangeUserState");
            uint            id           = ServerCore.GetIdByConnection(connection);
            UserData        user         = UserConnector.UpdateUserState(id, (bool)message.Data);
            List <UserData> friendList   = UserConnector.GetFriendList(id);
            RMessage        replyMessage = new RMessage(MessageType.CHANGE_USER_STATE_REPLY, user);

            foreach (UserData friend in friendList)
            {
                ClientWorker worker = ServerCore.GetWorkerById(friend.Id);
                if (worker != null)
                {
                    ServerCore.GetWorkerById(friend.Id).SendMessage(replyMessage);
                }
            }
            ServerCore.GetWorkerByConnection(connection).SendMessage(replyMessage);
        }
Пример #26
0
        public void Execute(ServerCore server, ClientConnection connection, string[] arguments)
        {
            if (arguments.Length == 1)
            {
                bool value;
                if (!bool.TryParse(arguments[0], out value))
                {
                    connection.SendChat("Invalid argument, try 'true' or 'false'");
                    return;
                }
                else
                {
                    server.EntitySpawningManager.DisableNPCSpawn = !value;
                }
            }

            connection.SendChat(string.Format("Npc spawn is {0}", server.EntitySpawningManager.DisableNPCSpawn ? "disabled" : "enabled"));
        }
        public void ServiceUdp(ulong time)
        {
            this.SendReceive();

            while (this.data_in.Count > 0)
            {
                try
                {
                    UdpProcessor.Eval(this.data_in.Dequeue(), this, time);
                }
                catch { }
            }

            if ((this.Timer_1_Second + 1000) < time)
            {
                this.Timer_1_Second = time;
                this.firewall_tests.ForEachWhere(x => x.Stop(), x => (x.Time + 10000) < time);
                this.firewall_tests.RemoveAll(x => x.Completed);

                if (this.TcpTester.IsTesting)
                {
                    this.TcpTester.TestNext(this);
                }
                else if (this.Showing)
                {
                    this.Push(time);
                }
            }

            if ((this.Timer_1_Minute + 60000) < time)
            {
                this.Timer_1_Minute = time;
                this.TcpTester.Timeout();
                UdpNodeManager.Expire(time);
            }

            if ((this.Timer_15_Minutes + 900000) < time)
            {
                this.Timer_15_Minutes = time;
                UdpNodeManager.Update(time);
                ServerCore.Log("local node list updated [" + UdpStats.SENDINFO + ":" + UdpStats.ACKINFO + ":" + UdpStats.ADDIPS + ":" + UdpStats.ACKIPS + "]");
                UdpStats.Reset();
            }
        }
Пример #28
0
        internal static void RunServerInConsole(bool isVerbose, bool autoStart, string startupFile)
        {
            Console.Clear();
            Console.WriteLine("Welcome to the Kinect With VR (KiwiVR) Server!");
            Console.WriteLine("Press the \"E\" key at any time to exit.");

            MasterSettings settings = new MasterSettings();

            try
            {
                settings = HelperMethods.LoadSettings(startupFile);
            }
            catch
            {
                HelperMethods.WriteToLog("Cannot open settings file!");
            }

            ServerCore server = new ServerCore(isVerbose, settings);
            for (int i = 0; i < server.serverMasterOptions.kinectOptionsList.Count; i++) //Launch the Kinects
            {
                server.kinects.Add(new KinectCore(server, null, server.serverMasterOptions.kinectOptionsList[i].kinectID));
            }
            server.launchServer(); //This will still try to launch with default settings even if the settings load fails

            bool running = true;
            while (running)
            {
                Thread.Sleep(100);
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey(false);
                    if (key.Key == ConsoleKey.E || (key.Key == ConsoleKey.C && key.Modifiers == ConsoleModifiers.Control))
                    {
                        running = false;
                    }
                }
            }

            Console.WriteLine("Shutting down the server.  Please wait...");
            server.stopServer();

            NativeInterop.FreeConsole();
        }
        private static void LoadDefaultList()
        {
            Nodes = new List <UdpNode>();

            using (FileStream fs = new FileStream("servers.dat", FileMode.Open, FileAccess.Read))
            {
                byte[] buffer = new byte[6];

                while (fs.Read(buffer, 0, buffer.Length) == 6)
                {
                    UdpNode node = new UdpNode();
                    node.IP   = new IPAddress(buffer.Take(4).ToArray());
                    node.Port = BitConverter.ToUInt16(buffer.ToArray(), 4);
                    Nodes.Add(node);
                }
            }

            ServerCore.Log("default node list loaded");
        }
Пример #30
0
        /* The GetResources MessageHandler
         * It handles messages of GET_QUESTION_RESOURCES_REQUEST type.
         */
        private static void GetResources(RMessage message, TcpClient connection)
        {
            Console.WriteLine("GetResources");
            List <DomainData>   domains   = (List <DomainData>)message.Data;
            List <ResourceData> resources = new List <ResourceData>();

            for (int i = 0; i < domains.Count; i++)
            {
                List <ResourceData> res = ResourceConnector.GetDomainResources(domains[i]);
                for (int j = 0; j < res.Count; j++)
                {
                    resources.Add(res[j]);
                }
            }

            RMessage replyMessage = new RMessage(MessageType.GET_QUESTION_DOMAINS_RESOURCES_REPLY, resources);

            ServerCore.GetWorkerByConnection(connection).SendMessage(replyMessage);
        }
Пример #31
0
        public void Execute(ServerCore server, ClientConnection connection, string[] arguments)
        {
            if (connection.SelectedNpc == null)
            {
                connection.SendChat("No npc is selected");
                return;
            }

            try
            {
                ServerDynamicEntity serverEntity;

                if (!server.AreaManager.TryFind(connection.SelectedNpc.DynamicId, out serverEntity))
                {
                    connection.SendChat("Can't find the server entity");
                    return;
                }

                var serverNpc = serverEntity as ServerNpc;

                if (serverNpc == null)
                {
                    connection.SendChat("Invalid type of the server entity");
                    return;
                }

                var humanAi = serverNpc.GeneralAI as HumanAI;

                if (humanAi == null)
                {
                    connection.SendChat("Invalid type of the AI");
                    return;
                }

                humanAi.Movement.Goto(connection.ServerEntity.DynamicEntity.Position.ToCubePosition());

                connection.SendChat("Command is sent!");
            }
            catch (Exception x)
            {
                connection.SendChat("Error: " + x);
            }
        }
Пример #32
0
        /// <summary>
        /// Only call this method on an another thread
        /// Starts the thread running the match
        /// </summary>
        public void ThreadStart()
        {
            MatchGameMessageHandler     matchGameHandler = new MatchGameMessageHandler(logger, this);
            MatchServerCoreEventHandler eventHandler     = new MatchServerCoreEventHandler();

            server         = new ServerCore(matchGameHandler, new ServerConnectionInfo(port), logger, eventHandler);
            pingDeterminer = new PingDeterminer(server.clientManager, server.messageSender, miliSecondPerTick, clock, updater);
            matchGameHandler.Init(serverExtensions, clock, eventHandler);
            var time = clock.GetTime();

            while (server.clientManager.GetClients().Count > 0 || timeClientsHaveToConnectWithin > clock.GetTime())
            {
                updater.Update();
                server.Update();
                System.Threading.Thread.Sleep(miliSecondPerTick);
            }

            logger.Log("Match ended");
        }
Пример #33
0
        /* The ResourceVote MessageHandler
         * It handles messages of VOTE_RESOURCE_REQUEST type.
         */
        private static void ResourceVote(RMessage message, TcpClient connection)
        {
            Console.WriteLine("VoteResource");
            ResourceVoteData resVote = (ResourceVoteData)message.Data;

            ResourceVoteData oldResVote = ResourceVoteConnector.UpdateVote(resVote);

            ResourceConnector.VoteResource(oldResVote, resVote);
            UserConnector.UpdateUserRank(ServerCore.GetIdByConnection(connection), Ranking.USER_VOTED_RESOURCE_VALUE);

            ResourceData editedResource = ResourceConnector.GetResource(resVote.Id_Resource);

            RMessage            replyMessage = new RMessage(MessageType.EDIT_RESOURCE_REPLY, editedResource);
            List <ClientWorker> clientList   = ServerCore.GetAllWorkers();

            foreach (ClientWorker client in clientList)
            {
                client.SendMessage(replyMessage);
            }
        }
Пример #34
0
        private void Window_Initialized(object sender, EventArgs e)
        {
            //Report to the log which Kinect versions are unavaliable
            if (!avaliableDLLs.HasKinectV1)
            {
                HelperMethods.WriteToLog("Warning: Kinect v1 support is unvaliable due to missing DLLs!", this);
            }
            if (!avaliableDLLs.HasKinectV2)
            {
                HelperMethods.WriteToLog("Warning: Kinect v2 support is unvaliable due to missing DLLs!", this);
            }
            if (!avaliableDLLs.HasNetworkedKinect)
            {
                HelperMethods.WriteToLog("Warning: Networked Kinect support is unvaliable due to missing DLLs!", this);
                //Remove the option to add a networked kinect if the dll isn't avaliable
                nkStackPanel.Visibility = System.Windows.Visibility.Collapsed;
                AddNKButton.IsEnabled = false;
            }

            //Setup the timer to update the GUI with the server runtime
            uptimeUpdateTimer = new System.Timers.Timer();
            uptimeUpdateTimer.Interval = 500;
            uptimeUpdateTimer.Elapsed += new System.Timers.ElapsedEventHandler(uptimeUpdateTimer_Elapsed);

            KinectBase.MasterSettings tempSettings = new KinectBase.MasterSettings();

            //Create the server core (this does NOT start the server)
            server = new ServerCore(verbose, tempSettings, this);

            //Set all the data for the data grids
            VoiceButtonDataGrid.ItemsSource = server.serverMasterOptions.voiceButtonCommands;
            VoiceTextDataGrid.ItemsSource = server.serverMasterOptions.voiceTextCommands;

            if (startupFile != null && startupFile != "")
            {
                try
                {
                    server.serverMasterOptions = HelperMethods.LoadSettings(startupFile);
                    UpdateGUISettings();
                }
                catch
                {
                    MessageBox.Show("Error: The startup settings file failed to load!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    HelperMethods.WriteToLog("Startup settings (" + startupFile + ") failed to load.");
                }
            }

            //TODO: Handle starting Kinects based on the loaded settings file
            //Initialize the data for the available Kinect v1s
            if (avaliableDLLs.HasKinectV1)
            {
                KinectV1Wrapper.StatusEventArgs[] currentStatuses = KinectV1Wrapper.StatusHelper.GetAllKinectsStatus();
                for (int i = 0; i < currentStatuses.Length; i++)
                {
                    AvailableKinectData tempData = new AvailableKinectData();

                    tempData.UniqueID = currentStatuses[i].UniqueKinectID;
                    tempData.Status = currentStatuses[i].Status;
                    tempData.KinectTypeString = GetKinectTypeString(currentStatuses[i].Status, currentStatuses[i].isXBox360Kinect);
                    tempData.kinectType = KinectVersion.KinectV1;

                    if (i == 0 && tempData.Status == KinectStatus.Connected)
                    {
                        tempData.UseKinect = true;
                        tempData.KinectID = 0;
                        server.serverMasterOptions.kinectOptionsList.Add((IKinectSettings)(new KinectV1Wrapper.Settings(tempData.UniqueID, (int)tempData.KinectID)));
                        server.kinects.Add((new KinectV1Wrapper.Core(ref server.serverMasterOptions, true, (int)tempData.KinectID)));
                        tempData.ServerStatus = "Running";
                    }
                    else
                    {
                        tempData.UseKinect = false;
                        tempData.KinectID = null;
                    }
                    tempData.PropertyChanged += useKinect_PropertyChanged;
                    availableKinects.Add(tempData);
                }
            }

            //Initialize the data for the available Kinect v2s
            if (avaliableDLLs.HasKinectV2)
            {
                KinectV2Wrapper.StatusHelper.StartKinectV2Service();
                KinectV2Wrapper.StatusEventArgs[] currentStatuses2 = KinectV2Wrapper.StatusHelper.GetAllKinectsStatus();
                for (int i = 0; i < currentStatuses2.Length; i++)
                {
                    AvailableKinectData tempData = new AvailableKinectData();

                    tempData.UniqueID = currentStatuses2[i].UniqueKinectID;
                    tempData.Status = currentStatuses2[i].Status;
                    tempData.KinectTypeString = "Kinect v2";
                    tempData.kinectType = KinectVersion.KinectV2;
                    //Note: Unlike the Kinect v1, we don't automatically launch a Kinect v2
                    tempData.UseKinect = false;
                    tempData.KinectID = null;
                    tempData.PropertyChanged += useKinect_PropertyChanged;
                    availableKinects.Add(tempData);
                }
            }

            KinectStatusBlock.Text = availableKinects.Count.ToString();
            kinectsAvailableDataGrid.ItemsSource = availableKinects;
            UpdatePageListing();
            GenerateImageSourcePickerLists();

            if (avaliableDLLs.HasKinectV1)
            {
                //Subscribe to the v1 status changed event
                KinectV1Wrapper.StatusHelper v1StatusHelper = new KinectV1Wrapper.StatusHelper();
                v1StatusHelper.StatusChanged += v1StatusHelper_KinectV1StatusChanged;
            }
            if (avaliableDLLs.HasKinectV2)
            {
                //Subscribe to the v2 status changed event
                KinectV2Wrapper.StatusHelper v2StatusHelper = new KinectV2Wrapper.StatusHelper();
                v2StatusHelper.StatusChanged += v2StatusHelper_KinectV2StatusChanged;
            }

            //Populate the skeleton data and set the binding for the data grid
            GenerateSkeletonDataGridData();
            SkeletonSettingsDataGrid.ItemsSource = server.serverMasterOptions.mergedSkeletonOptions.individualSkeletons;

            //Populate and setup the voice recognition lists
            GenerateVoiceRecogEngineList();
            GenerateAudioSourceList();
            VoiceKinectComboBox.SelectedIndex = 0;

            //Set defaults where needed
            FeedbackJointTypeComboBox.SelectedIndex = 0;
            SkelSortModeComboBox.SelectedIndex = 5;

            //Set the items source for the servers display grid
            ServersDataGrid.ItemsSource = configuredServers;

            //Set the initial shader for the depth image
            depthEffect = new Shaders.NoScalingEffect();
            DepthImage.Effect = depthEffect;

            if (startOnLaunch)
            {
                startServerButton_Click(this, new RoutedEventArgs());
            }
        }
Пример #35
0
 internal static void RegisterPluginInstance(ServerCore serverCore, LibMessenger pluginInstance)
 {
     _pluginInstanceLookup[serverCore] = pluginInstance;
 }
Пример #36
0
        internal static void RunServerInConsole(bool isVerbose, bool autoStart, string startupFile, AvaliableDLLs dlls)
        {
            Console.Clear();
            Console.WriteLine("Welcome to the Kinect With VR (KVR) Server!");
            Console.WriteLine("Press the \"E\" key at any time to exit.");

            //Notify the user if DLLs are missing
            if (!dlls.HasKinectV1)
            {
                Console.WriteLine("Warning: Kinect v1 support is unavaliable due to missing DLLs");
            }
            if (!dlls.HasKinectV2)
            {
                Console.WriteLine("Warning: Kinect v2 support is unavaliable due to missing DLLs");
            }
            if (!dlls.HasNetworkedKinect)
            {
                Console.WriteLine("Warning: Networked Kinect support is unavaliable due to missing DLLs");
            }

            KinectBase.MasterSettings settings = new KinectBase.MasterSettings();

            try
            {
                settings = HelperMethods.LoadSettings(startupFile);
            }
            catch
            {
                HelperMethods.WriteToLog("Cannot open settings file!");
            }

            ServerCore server = new ServerCore(isVerbose, settings);
            for (int i = 0; i < server.serverMasterOptions.kinectOptionsList.Count; i++) //Launch the Kinects
            {
                if (server.serverMasterOptions.kinectOptionsList[i].version == KinectBase.KinectVersion.KinectV1)
                {
                    if (dlls.HasKinectV1)
                    {
                        //server.kinects.Add(new KinectV1Core.KinectCoreV1(ref server.serverMasterOptions, false, server.serverMasterOptions.kinectOptionsList[i].kinectID));
                        server.kinects.Add(new KinectV1Wrapper.Core(ref server.serverMasterOptions, false, server.serverMasterOptions.kinectOptionsList[i].kinectID));
                    }
                    else
                    {
                        Console.WriteLine("Cannot load Kinect v1 with ID: {0} due to missing DLLs.", server.serverMasterOptions.kinectOptionsList[i].kinectID);
                    }
                }
                else if (server.serverMasterOptions.kinectOptionsList[i].version == KinectBase.KinectVersion.KinectV2)
                {
                    if (dlls.HasKinectV2)
                    {
                        server.kinects.Add(new KinectV2Wrapper.Core(ref server.serverMasterOptions, false, server.serverMasterOptions.kinectOptionsList[i].kinectID));
                    }
                    else
                    {
                        Console.WriteLine("Cannot load Kinect v2 with ID: {0} due to missing DLLs.", server.serverMasterOptions.kinectOptionsList[i].kinectID);
                    }
                }
                else if (server.serverMasterOptions.kinectOptionsList[i].version == KinectBase.KinectVersion.NetworkKinect)
                {
                    if (dlls.HasNetworkedKinect)
                    {
                        server.kinects.Add(new NetworkKinectWrapper.Core(ref server.serverMasterOptions, false, server.serverMasterOptions.kinectOptionsList[i].kinectID, server.serverMasterOptions.kinectOptionsList[i].uniqueKinectID));
                    }
                    else
                    {
                        Console.WriteLine("Cannot load network Kinect with ID: {0} due to missing DLLs.", server.serverMasterOptions.kinectOptionsList[i].kinectID);
                    }
                }
                else
                {
                    Console.WriteLine("Kinect number {0} was of an unknown version and could not be opened.", i);
                }
            }
            server.launchServer(); //This will still try to launch with default settings even if the settings load fails

            bool running = true;
            while (running)
            {
                Thread.Sleep(100);
                if (Console.KeyAvailable)
                {
                    ConsoleKeyInfo key = Console.ReadKey(false);
                    if (key.Key == ConsoleKey.E || (key.Key == ConsoleKey.C && key.Modifiers == ConsoleModifiers.Control))
                    {
                        running = false;
                    }
                }
            }

            Console.WriteLine(); //Write a blank so the next statement has its own line
            Console.WriteLine("Shutting down the server.  Please wait...");
            server.stopServer();

            NativeInterop.FreeConsole();
        }
Пример #37
0
        private void Window_Initialized(object sender, EventArgs e)
        {
            //Setup the timer to update the GUI with the server runtime
            uptimeUpdateTimer = new System.Timers.Timer();
            uptimeUpdateTimer.Interval = 500;
            uptimeUpdateTimer.Elapsed += new System.Timers.ElapsedEventHandler(uptimeUpdateTimer_Elapsed);

            MasterSettings tempSettings = new MasterSettings();

            //Create the server core (this does NOT start the server)
            server = new ServerCore(verbose, tempSettings, this);

            //Set all the data for the data grids
            VoiceButtonDataGrid.ItemsSource = server.serverMasterOptions.voiceButtonCommands;
            VoiceTextDataGrid.ItemsSource = server.serverMasterOptions.voiceTextCommands;

            KinectStatusBlock.Text = "1";

            if (startupFile != null && startupFile != "")
            {
                try
                {
                    server.serverMasterOptions = HelperMethods.LoadSettings(startupFile);
                    UpdateGUISettings();
                }
                catch
                {
                    MessageBox.Show("Error: The startup settings file failed to load!", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
                    HelperMethods.WriteToLog("Startup settings (" + startupFile + ") failed to load.");
                }
            }

            //TODO: Handle starting Kinects based on the loaded settings file
            //Initialize the data for the available Kinects
            for (int i = 0; i < KinectSensor.KinectSensors.Count; i++)
            {
                AvailableKinectData tempData = new AvailableKinectData();
                tempData.ConnectionID = KinectSensor.KinectSensors[i].DeviceConnectionId;
                tempData.Status = KinectSensor.KinectSensors[i].Status;
                if (i == 0 && tempData.Status == KinectStatus.Connected)
                {
                    tempData.UseKinect = true;
                    tempData.KinectID = 0;
                    server.serverMasterOptions.kinectOptionsList.Add(new KinectSettings(tempData.ConnectionID, (int)tempData.KinectID));
                    server.kinects.Add(new KinectCore(server, this, (int)tempData.KinectID));
                    tempData.ServerStatus = "Running";
                }
                else
                {
                    tempData.UseKinect = false;
                    tempData.KinectID = null;
                }
                tempData.PropertyChanged += useKinect_PropertyChanged;
                availableKinects.Add(tempData);
            }
            kinectsAvailableDataGrid.ItemsSource = availableKinects;
            UpdatePageListing();
            GenerateImageSourcePickerLists();
            KinectSensor.KinectSensors.StatusChanged += KinectSensors_StatusChanged;

            //Populate the skeleton data and set the binding for the data grid
            GenerateSkeletonDataGridData();
            SkeletonSettingsDataGrid.ItemsSource = server.serverMasterOptions.skeletonOptions.individualSkeletons;

            //Populate and setup the voice recognition lists
            GenerateVoiceRecogEngineList();
            GenerateAudioSourceList();
            VoiceKinectComboBox.SelectedIndex = 0;

            //Set defaults where needed
            FeedbackJointTypeComboBox.SelectedIndex = 0;
            SkelSortModeComboBox.SelectedIndex = 5;

            if (startOnLaunch)
            {
                startServerButton_Click(this, new RoutedEventArgs());
            }
        }
Пример #38
0
 public PublishingService()
 {
     _serverCore = new ServerCore();
 }
Пример #39
0
 static void Main(string[] args)
 {
     AutoMapperConfig.Initialize();
     var server = new ServerCore();
     server.Start();
 }
Пример #40
0
 internal static void InitialiseServerCore()
 {
     ServerCore = new ServerCore();
 }