public PoroServer(PoroServerSettings settings) { _settings = settings; //Create the Authentication Server to handle login requests _auth = new AuthServer(HandleAuth, _settings.AuthLocations); //Load the certificate for the RTMPS server var certificateStore = new X509Store(StoreName.Root, StoreLocation.LocalMachine); certificateStore.Open(OpenFlags.MaxAllowed); //Store the certificate if it's not in the local store var _rtmpsCert = new X509Certificate2(_settings.CertFilename, ""); if (!StoreContainsCertificate(certificateStore.Certificates, _rtmpsCert)) { certificateStore.Add(_rtmpsCert); } certificateStore.Close(); //Generate the SerializationContext var context = new SerializationContext(); var structures = Assembly.GetExecutingAssembly().GetTypes().Where(x => String.Equals(x.Namespace, "PoroLib.Structures", StringComparison.Ordinal)); foreach (Type ObjectType in structures) { context.Register(ObjectType); } //Create the RTMPS server with the context and certificate _server = new RtmpServer(new IPEndPoint(IPAddress.Parse(_settings.RTMPSHost), _settings.RTMPSPort), context, _rtmpsCert); _server.ClientCommandReceieved += ClientCommandReceieved; _server.ClientMessageReceived += ClientMessageReceived; //Set up the handler _handler = new MessageHandler(); _handler.Register("LoginService"); _handler.Register("MatchmakerService"); _handler.Register("ClientFacadeService"); _handler.Register("InventoryService"); //Set up the forwarder _forwarder = new MessageForwarder(context); //Set up the property redirector _redirector = new PropertyRedirector(_settings); }
public PoroServer(PoroServerSettings settings) { _settings = settings; //Create the Authentication Server to handle login requests and client page _auth = new AuthServer(HandleWebServ, _settings.AuthLocations); //Load the certificate store for the RTMPS server var certificateStore = new X509Store(StoreName.Root, StoreLocation.LocalMachine); certificateStore.Open(OpenFlags.MaxAllowed); //Remove last certificate in case it wasn't deleted on close foreach (var cert in certificateStore.Certificates) { if (cert.IssuerName.Name == string.Format("CN={0}", _settings.RTMPSHost)) { certificateStore.Remove(cert); } } //Generate new certificate for this run and add it to the store. var _rtmpsCert = CertGen.CreateSelfSignedCertificate(_settings.RTMPSHost); certificateStore.Add(_rtmpsCert); certificateStore.Close(); //Generate the SerializationContext _context = new SerializationContext(); var structures = Assembly.GetExecutingAssembly().GetTypes().Where(x => String.Equals(x.Namespace, "PoroLib.Structures", StringComparison.Ordinal)); foreach (Type ObjectType in structures) { _context.Register(ObjectType); } //Create the RTMPS server with the context and certificate _server = new RtmpServer(new IPEndPoint(IPAddress.Parse(_settings.RTMPSHost), _settings.RTMPSPort), _context, _rtmpsCert); _server.ClientCommandReceieved += ClientCommandReceieved; _server.ClientMessageReceived += ClientMessageReceived; //Set up the handler _handler = new MessageHandler(); _handler.Register("LoginService"); _handler.Register("MatchmakerService"); _handler.Register("ClientFacadeService"); _handler.Register("InventoryService"); _handler.Register("MasteryBookService"); _handler.Register("SummonerRuneService"); _handler.Register("PlayerPreferencesService"); _handler.Register("LcdsGameInvitationService"); _handler.Register("SummonerTeamService"); //Set up the forwarder _forwarder = new MessageForwarder(_context); //Set up the property redirector _redirector = new PropertyRedirector(_settings); //Set up the data loader _data = new DataLoader(); _redirector.PatcherFound += new PropertyRedirector.PatcherFoundHandler(_data.LoadData); //Set up the user server _users = new UserHandler(); }