///////////////////////////////////////////

        public GameNetworkClient(bool entitySystemServiceEnabled)
        {
            if (instance != null)
                Log.Fatal("GameNetworkClient.GameNetworkClient: instance != null.");
            instance = this;

            //register network services

            //register user management service
            userManagementService = new UserManagementClientNetworkService();
            RegisterService(userManagementService);

            //register custom messages service
            customMessagesService = new CustomMessagesClientNetworkService();
            RegisterService(customMessagesService);

            //register chat service
            chatService = new ChatClientNetworkService(userManagementService);
            RegisterService(chatService);

            //register entity system service
            if (entitySystemServiceEnabled)
            {
                entitySystemService = new EntitySystemClientNetworkService(userManagementService);
                RegisterService(entitySystemService);
            }
        }
        ///////////////////////////////////////////

        public GameNetworkClient(bool entitySystemServiceEnabled)
        {
            if (instance != null)
            {
                Log.Fatal("GameNetworkClient.GameNetworkClient: instance != null.");
            }
            instance = this;

            //register network services

            //register user management service
            userManagementService = new UserManagementClientNetworkService();
            RegisterService(userManagementService);

            //register custom messages service
            customMessagesService = new CustomMessagesClientNetworkService();
            RegisterService(customMessagesService);

            //register chat service
            chatService = new ChatClientNetworkService(userManagementService);
            RegisterService(chatService);

            //register entity system service
            if (entitySystemServiceEnabled)
            {
                entitySystemService = new EntitySystemClientNetworkService(userManagementService);
                RegisterService(entitySystemService);
            }
        }
Пример #3
0
 public void SayPrivate( string text, UserManagementClientNetworkService.UserInfo toUser )
 {
     MessageType messageType = GetMessageType( "textToServer" );
     SendDataWriter writer = BeginMessage( messageType );
     writer.Write( text );
     writer.WriteVariableUInt32( toUser.Identifier );
     EndMessage();
 }
Пример #4
0
        ///////////////////////////////////////////
        public ChatClientNetworkService( UserManagementClientNetworkService userManagementService )
            : base("Chat", 3)
        {
            this.userManagementService = userManagementService;

            //register message types
            RegisterMessageType( "textToServer", 1 );
            RegisterMessageType( "textToClient", 2, ReceiveMessage_TextToClient );
        }
Пример #5
0
        ///////////////////////////////////////////

        public ChatClientNetworkService(UserManagementClientNetworkService userManagementService)
            : base("Chat", 3)
        {
            this.userManagementService = userManagementService;

            //register message types
            RegisterMessageType("textToServer", 1);
            RegisterMessageType("textToClient", 2, ReceiveMessage_TextToClient);
        }
        ///////////////////////////////////////////

        public EntitySystemClientNetworkService(UserManagementClientNetworkService userManagementService)
            : base("EntitySystem", 4)
        {
            this.userManagementService = userManagementService;

            //register message types
            for (int n = 0; n < 6; n++)
            {
                entitySystemInternalMessageTypes[n] = RegisterMessageType(
                    string.Format("entitySystemInternal{0}", n), (byte)(n + 1),
                    ReceiveMessage_EntitySystemInternal);
            }
            RegisterMessageType("worldCreateBeginToClient", 7, ReceiveMessage_WorldCreateBeginToClient);
            RegisterMessageType("worldCreateEndToClient", 8, ReceiveMessage_WorldCreateEndToClient);
            RegisterMessageType("worldDestroyToClient", 9, ReceiveMessage_WorldDestroyToClient);
            RegisterMessageType("worldIdentifierToServer", 10);

            networkingInterface = new ClientEntitySystemNetworkingInterface(this);
        }
Пример #7
0
        ///////////////////////////////////////////
        public EntitySystemClientNetworkService( UserManagementClientNetworkService userManagementService )
            : base("EntitySystem", 4)
        {
            this.userManagementService = userManagementService;

            //register message types
            for( int n = 0; n < 6; n++ )
            {
                entitySystemInternalMessageTypes[ n ] = RegisterMessageType(
                    string.Format( "entitySystemInternal{0}", n ), (byte)( n + 1 ),
                    ReceiveMessage_EntitySystemInternal );
            }
            RegisterMessageType( "worldCreateBeginToClient", 7, ReceiveMessage_WorldCreateBeginToClient );
            RegisterMessageType( "worldCreateEndToClient", 8, ReceiveMessage_WorldCreateEndToClient );
            RegisterMessageType( "worldDestroyToClient", 9, ReceiveMessage_WorldDestroyToClient );
            RegisterMessageType( "worldIdentifierToServer", 10 );

            networkingInterface = new ClientEntitySystemNetworkingInterface( this );
        }
Пример #8
0
 private void ChatService_ReceiveText(ChatClientNetworkService sender,
     UserManagementClientNetworkService.UserInfo fromUser, string text)
 {
     string userName = fromUser != null ? fromUser.Name : "(null)";
     Log("{0}: {1}", userName, text);
 }
Пример #9
0
 private void UserManagementService_RemoveUserEvent(UserManagementClientNetworkService sender,
     UserManagementClientNetworkService.UserInfo user)
 {
     listBoxUsers.Items.Remove(user);
 }
Пример #10
0
        void Client_ChatService_ReceiveText( ChatClientNetworkService sender,
			UserManagementClientNetworkService.UserInfo fromUser, string text )
        {
        }
Пример #11
0
        void UserManagementService_AddUserEvent( UserManagementClientNetworkService sender,
			UserManagementClientNetworkService.UserInfo user )
        {
            listBoxUsers.Items.Add( user );
        }
Пример #12
0
            public Client_Player( uint identifier, string name, bool bot,
				UserManagementClientNetworkService.UserInfo user )
            {
                this.identifier = identifier;
                this.name = name;
                this.bot = bot;
                this.user = user;
            }
Пример #13
0
        public Client_Player Client_GetPlayer(
			UserManagementClientNetworkService.UserInfo user )
        {
            //slowly. need Dictionary.
            foreach( Client_Player player in client_players )
            {
                if( player.User == user )
                    return player;
            }
            return null;
        }
 private void Client_ChatService_ReceiveText(ChatClientNetworkService sender,
     UserManagementClientNetworkService.UserInfo fromUser, string text)
 {
     string userName = fromUser != null ? fromUser.Name : "(null)";
     AddScreenMessage(string.Format("{0}: {1}", userName, text));
 }