Exemplo n.º 1
0
 internal Player(Func <bool> hasMount, UltimaServer server, Legacy legacyApi, EventJournalSource eventJournalSource)
 {
     this.hasMount           = hasMount;
     this.server             = server;
     this.legacyApi          = legacyApi;
     this.eventJournalSource = eventJournalSource;
 }
Exemplo n.º 2
0
 public DialogBoxObservers(UltimaServer server, EventJournalSource eventJournalSource, PacketDefinitionRegistry packetRegistry)
 {
     this.server             = server;
     this.eventJournalSource = eventJournalSource;
     this.packetRegistry     = packetRegistry;
     server.RegisterFilter(FilterServerPackets);
 }
Exemplo n.º 3
0
        public PlayerObservers(Player player, UltimaClient client, UltimaServer server, IConsole console,
                               Legacy legacyApi, GameObjectCollection gameObjects, EventJournalSource eventJournalSource,
                               PacketDefinitionRegistry packetRegistry)
        {
            this.client             = client;
            this.server             = server;
            this.player             = player;
            this.console            = console;
            this.legacyApi          = legacyApi;
            this.gameObjects        = gameObjects;
            this.eventJournalSource = eventJournalSource;
            this.packetRegistry     = packetRegistry;
            IClientPacketSubject clientPacketSubject = client;

            clientPacketSubject.Subscribe(PacketDefinitions.MoveRequest, HandleMoveRequest);
            clientPacketSubject.RegisterOutputFilter(FilterSentClientPackets);

            server.RegisterFilter(FilterServerPackets);

            server.Subscribe(PacketDefinitions.CharacterLocaleAndBody, HandleCharLocaleAndBodyPacket);
            server.Subscribe(PacketDefinitions.DrawGamePlayer, HandleDrawGamePlayerPacket);
            server.Subscribe(PacketDefinitions.CharMoveRejection, HandleCharMoveRejectionPacket);
            server.Subscribe(PacketDefinitions.UpdateCurrentHealth, HandleUpdateCurrentHealthPacket);
            server.Subscribe(PacketDefinitions.UpdateCurrentStamina, HandleUpdateCurrentStaminaPacket);
            server.Subscribe(PacketDefinitions.UpdateCurrentMana, HandleUpdateCurrentManaPacket);
            server.Subscribe(PacketDefinitions.StatusBarInfo, HandleStatusBarInfoPacket);
            server.Subscribe(PacketDefinitions.SendSkills, HandleSendSkillsPacket);
            server.Subscribe(PacketDefinitions.DrawObject, HandleDrawObjectPacket);
            server.Subscribe(PacketDefinitions.AllowRefuseAttack, HandleAllowRefuseAttack);
            server.Subscribe(PacketDefinitions.UpdatePlayer, HandleUpdatePlayerPacket);
            server.Subscribe(PacketDefinitions.BoatMoving, HandleBoatMovingPacket);

            clientPacketSubject.Subscribe(PacketDefinitions.RequestSkills, HandleRequestSkills);
        }
Exemplo n.º 4
0
 internal Chat(UltimaServer ultimaServer, Action notifyAction, IConsole console, IKeywordSource keywordSource)
 {
     this.ultimaServer = ultimaServer;
     this.notifyAction = notifyAction;
     this.console      = console;
     keywordParser     = new KeywordParser(keywordSource);
 }
Exemplo n.º 5
0
        public HeadlessClient(Legacy legacyApi, IConsole console, HeadlessStartConfig startConfig)
        {
            this.legacyApi             = legacyApi;
            this.console               = console;
            this.startConfig           = startConfig;
            packetRegistry             = PacketDefinitionRegistryFactory.CreateClassicClient(startConfig.ClientVersion);
            diagnosticProvider         = new InfusionDiagnosticPushStreamProvider(LogConfig, console);
            serverDiagnosticPushStream =
                new CompositeDiagnosticPushStream(new ConsoleDiagnosticPushStream(packetLogger, "headless -> server", packetRegistry),
                                                  new InfusionBinaryDiagnosticPushStream(DiagnosticStreamDirection.ClientToServer, diagnosticProvider.GetStream));
            serverDiagnosticPullStream = new ConsoleDiagnosticPullStream(packetLogger, "server -> headless", packetRegistry);

            serverConnection = new ServerConnection(ServerConnectionStatus.Initial, serverDiagnosticPullStream,
                                                    serverDiagnosticPushStream, packetRegistry, startConfig.Encryption);
            serverConnection.PacketReceived += ServerConnectionOnPacketReceived;
            ultimaServer = new UltimaServer(serverPacketHandler, SendToServer, packetRegistry);

            serverPacketHandler = new ServerPacketHandler(packetRegistry);
            clientPacketHandler = new ClientPacketHandler(packetRegistry);
            serverEndpoint      = startConfig.ServerEndPoint;

            ultimaClient = new UltimaClient(clientPacketHandler, SendToClient);

            serverPacketHandler.RegisterFilter(FilterServerPacket);
            serverPacketHandler.Subscribe(PacketDefinitions.GameServerList, HandleGameServerList);
            serverPacketHandler.Subscribe(PacketDefinitions.CharactersStartingLocations, HandleCharactersStartingLocationsPacket);
            serverPacketHandler.Subscribe(PacketDefinitions.EnableLockedClientFeatures, HandleEnableLockedClientFeatures);

            clientPacketHandler.Subscribe(PacketDefinitions.LoginRequest, HandleLoginRequest);
            clientPacketHandler.Subscribe(PacketDefinitions.GameServerLoginRequest, HandleGameServerLoginRequest);
            clientPacketHandler.Subscribe(PacketDefinitions.SelectServerRequest, HandleSelectServerRequest);
        }
Exemplo n.º 6
0
        internal InfusionTestProxy(ITimeSource timeSource, PacketDefinitionRegistry packetRegistry = null)
        {
            packetRegistry      = packetRegistry ?? PacketDefinitionRegistryFactory.CreateClassicClient();
            ServerPacketHandler = new ServerPacketHandler(PacketDefinitionRegistryFactory.CreateClassicClient());
            ClientPacketHandler = new ClientPacketHandler(PacketDefinitionRegistryFactory.CreateClassicClient());
            Server = new UltimaServer(ServerPacketHandler, packet =>
            {
                var filteredPacket = ClientPacketHandler.FilterOutput(packet);
                if (filteredPacket.HasValue)
                {
                    packetsSentToServer.Add(filteredPacket.Value);
                }
            }, packetRegistry);
            Client = new UltimaClient(ClientPacketHandler, packet =>
            {
                var filteredPacket = ServerPacketHandler.FilterOutput(packet);
                if (filteredPacket.HasValue)
                {
                    packetsSentToClient.Add(filteredPacket.Value);
                }
            });

            var console = new NullConsole();

            Api = new Legacy(new LogConfiguration(), new CommandHandler(console), Server, Client, console, packetRegistry,
                             timeSource, ClilocSource, KeywordSource, new MemoryConfigBagRepository(), new NullInjectionWindow(), new NullSoundPlayer());
            UO.Initialize(Api);
            ServerApi = new TestServerApi(PacketReceivedFromServer, Api);
        }
Exemplo n.º 7
0
        public InfusionTestProxy()
        {
            ServerPacketHandler = new ServerPacketHandler();
            ClientPacketHandler = new ClientPacketHandler();
            Server = new UltimaServer(ServerPacketHandler, packet =>
            {
                var filteredPacket = ClientPacketHandler.FilterOutput(packet);
                if (filteredPacket.HasValue)
                {
                    packetsSentToServer.Add(filteredPacket.Value);
                }
            });
            Client = new UltimaClient(ClientPacketHandler, packet =>
            {
                var filteredPacket = ServerPacketHandler.FilterOutput(packet);
                if (filteredPacket.HasValue)
                {
                    packetsSentToClient.Add(filteredPacket.Value);
                }
            });

            var logger = new NullLogger();

            Api = new Legacy(new Configuration(), new CommandHandler(logger), Server, Client, logger);
        }
Exemplo n.º 8
0
 public ServerObservers(UltimaServer server, IClientPacketSubject client, PacketDefinitionRegistry packetRegistry)
 {
     server.Subscribe(PacketDefinitions.ServerListing, HandleServerListing);
     server.Subscribe(PacketDefinitions.GameServerList, HandleGameServerList);
     server.RegisterFilter(HandleRunUOProtocolExtension);
     client.Subscribe(PacketDefinitions.SelectServerRequest, HandleSelectServerRequest);
     client.Subscribe(PacketDefinitions.LoginCharacter, HandleSelectLoginCharacterRequest);
     this.packetRegistry = packetRegistry;
     this.server         = server;
 }
Exemplo n.º 9
0
        public GumpObservers(UltimaServer server, UltimaClient client, EventJournalSource eventSource, Cancellation cancellation)
        {
            this.server       = server;
            this.client       = client;
            this.eventSource  = eventSource;
            this.cancellation = cancellation;
            server.RegisterFilter(FilterSendGumpMenuDialog);

            IClientPacketSubject clientPacketSubject = client;

            clientPacketSubject.RegisterFilter(FilterGumpMenuSelection);
            clientPacketSubject.Subscribe(PacketDefinitions.GumpMenuSelection, GumpMenuSelectionRequest);
        }
Exemplo n.º 10
0
        internal Legacy(Configuration configuration, CommandHandler commandHandler,
                        UltimaServer ultimaServer, UltimaClient ultimaClient, ILogger logger)
        {
            Trace = new GlobalTrace(logger);

            cancellation       = new Cancellation(() => CancellationToken);
            eventJournalSource = new EventJournalSource();
            Me = new Player(() => GameObjects.OfType <Item>().OnLayer(Layer.Mount).FirstOrDefault() != null,
                            ultimaServer, this, eventJournalSource);
            gumpObservers       = new GumpObservers(ultimaServer, ultimaClient, eventJournalSource, cancellation);
            GameObjects         = new GameObjectCollection(Me);
            Items               = new ItemCollection(GameObjects);
            Mobiles             = new MobileCollection(GameObjects);
            Corpses             = new CorpseCollection(GameObjects);
            itemsObserver       = new ItemsObservers(GameObjects, ultimaServer, ultimaClient, this, eventJournalSource);
            Me.LocationChanged += itemsObserver.OnPlayerPositionChanged;
            journalSource       = new SpeechJournalSource();
            journalSource.NewMessageReceived +=
                (sender, entry) => eventJournalSource.Publish(new SpeechReceivedEvent(entry));
            Journal          = new SpeechJournal(journalSource, cancellation, () => DefaultTimeout, Trace.JournalTrace);
            journalObservers = new JournalObservers(journalSource, ultimaServer);
            targeting        = new Targeting(ultimaServer, ultimaClient, cancellation, eventJournalSource);

            blockedPacketsFilters = new BlockedClientPacketsFilters(ultimaClient);
            lightObserver         = new LightObserver(ultimaServer, ultimaClient, Me, this);
            weatherObserver       = new WeatherObserver(ultimaServer, ultimaClient, this);
            soundObserver         = new SoundObserver(ultimaServer, eventJournalSource);
            questArrowObserver    = new QuestArrowObserver(ultimaServer, eventJournalSource);
            shapeShifter          = new ShapeshiftingFilter(ultimaServer, ultimaClient);
            var speechRequestObserver = new SpeechRequestObserver(ultimaClient, commandHandler, eventJournalSource, logger);
            var staminaFilter         = new StaminaFilter(ultimaServer, ultimaClient);

            dialogBoxObervers = new DialogBoxObservers(ultimaServer, eventJournalSource);

            playerObservers = new PlayerObservers(Me, ultimaClient, ultimaServer, logger, this, GameObjects, eventJournalSource);
            playerObservers.WalkRequestDequeued += Me.OnWalkRequestDequeued;

            this.logger = logger;
            Server      = ultimaServer;
            Client      = ultimaClient;

            CommandHandler = commandHandler;
            CommandHandler.CancellationTokenCreated += (sender, token) => CancellationToken = token;

            Configuration      = configuration;
            legacyEventJournal = CreateEventJournal();

            ClientFilters = new LegacyFilters(staminaFilter, lightObserver, weatherObserver, soundObserver, shapeShifter);
            RegisterDefaultCommands();
        }
Exemplo n.º 11
0
        public Targeting(UltimaServer server, UltimaClient client, Cancellation cancellation,
                         EventJournalSource eventSource)
        {
            this.server       = server;
            this.client       = client;
            this.cancellation = cancellation;
            this.eventSource  = eventSource;
            server.Subscribe(PacketDefinitions.TargetCursor, HanldeServerTargetCursorPacket);
            eventJournal = new EventJournal(eventSource, cancellation);

            IClientPacketSubject clientPacketSubject = client;

            clientPacketSubject.RegisterFilter(FilterClientTargetCursorPacket);

            IServerPacketSubject serverPacketSubject = server;

            serverPacketSubject.RegisterFilter(FilterSeverTargetCursorPacket);
        }
Exemplo n.º 12
0
        public GumpObservers(UltimaServer server, UltimaClient client, EventJournalSource eventSource,
                             Cancellation cancellation, PacketDefinitionRegistry packetRegistry)
        {
            this.server         = server;
            this.client         = client;
            this.eventSource    = eventSource;
            this.cancellation   = cancellation;
            this.packetRegistry = packetRegistry;
            server.RegisterFilter(FilterSendGumpMenuDialog);

            IClientPacketSubject clientPacketSubject = client;

            clientPacketSubject.RegisterFilter(FilterGumpMenuSelection);
            clientPacketSubject.Subscribe(PacketDefinitions.GumpMenuSelection, GumpMenuSelectionRequest);

            IServerPacketSubject serverPacketSubject = server;

            serverPacketSubject.Subscribe(PacketDefinitions.SendGumpMenuDialog, HandleGump);
            serverPacketSubject.Subscribe(PacketDefinitions.CompressedGump, HandleGump);
        }
Exemplo n.º 13
0
 public DialogBoxObservers(UltimaServer server, EventJournalSource eventJournalSource)
 {
     this.server             = server;
     this.eventJournalSource = eventJournalSource;
     server.RegisterFilter(FilterServerPackets);
 }