Exemplo n.º 1
0
 public void LoadEventSenders()
 {
     this.serviceLocatorMock = new Mock<IServiceLocator>();
     this.serviceLocatorMock.Setup(x => x.GetService<IServiceLocator>()).Returns(this.serviceLocatorMock.Object);
     this.server = new Battlefield3Server(serviceLocatorMock.Object);
     this.eventSenders = Utilities.LoadClassesFromDirectory<ICanSendEvents>(AppDomain.CurrentDomain.BaseDirectory);
 }
Exemplo n.º 2
0
        /// <summary>
        /// creates a wrapper around the core Session, which is able to convert the packet data used
        /// in the battlefield 3 protocol into normal bytes
        /// </summary>
        /// <param name="session"></param>
        /// <param name="server"> </param>
        public PacketSession(IRconSession session, Battlefield3Server server)
        {
            Session = session;
            Server = server;
            PacketSerializer = new PacketSerializer();
            PacketSequence = new PacketSequence();
            EventsSent = new List<Packet>();

            // create the hash value for validating crypted password
            HashValue = Guid.NewGuid().ToString().Replace("-", string.Empty);

            this.CommandHandlersList = new CommandHandlersList();
            this.CommandHandlersList.Add(new MapListCommandHandlers());
            this.CommandHandlersList.Add(new BanListCommandHandlers());
            this.CommandHandlersList.Add(new VarsCommandHandlers());
            this.CommandHandlersList.Add(new ReservedSlotsListCommandHandlers());
            this.CommandHandlersList.Add(new AdminCommandHandlers());
            this.CommandHandlersList.Add(new NotAuthenticatedCommandHandlers(server.ServiceLocator));

            this.ClientCommandReceived += CommandHandlersList.OnCommandReceived;
            this.ServerEventResponseReceived += OnServerEventResponseReceived;

            if (session != null)
            {
                Session.DataReceived += OnDataReceived;
                Session.DataSent += OnDataSent;
                Session.Closed += SessionOnClosed;
            }
        }
        public void TestSetup()
        {
            SocketServer = new ServerInstance(11000, 1);
            var protocol = new Battlefield3Protocol() {Bf3Server = {Password = "******"}};
            SocketServer.SetProtocol(protocol);

            Socket = new Socket(AddressFamily.InterNetwork, SocketType.Stream, ProtocolType.Tcp);

            ServerInstance = protocol.Bf3Server;
            Session = Connect();
            Session.StartReceiving();
        }