public StructureItemDetails GetStructureDetails(ulong objectID, ulong?ownerID) { GetStructureItemDetailsRequest req = null; if (ownerID.HasValue) { req = GetStructureItemDetailsRequest.CreateBuilder() .SetObjectId(objectID) .SetOwnerObjectId(ownerID.Value) .Build(); } else { req = GetStructureItemDetailsRequest.CreateBuilder() .SetObjectId(objectID) .Build(); } RcfProtoChannel channel = (RcfProtoChannel)RPCServiceStub.Channel; RPCServiceStub.GetStructureItemDetails(null, req, null); GetStructureItemDetailsResponse res = (GetStructureItemDetailsResponse)channel.GetResponse(); if (res != null) { var structDetails = res.StructuresList.FirstOrDefault(); if (structDetails != null) { return(StructureTransform.TransformStructureDetails(structDetails)); } } return(null); }
protected List <AccountResponse> GetResponseFromBuilder(GetAccountRequest req) { RcfProtoChannel channel = (RcfProtoChannel)RPCServiceStub.Channel; RPCServiceStub.GetAccount(null, req, null); GetAccountResponse res = (GetAccountResponse)channel.GetResponse(); if (res != null) { List <AccountResponse> accounts = new List <AccountResponse>(); foreach (var account in res.AccountsList) { AccountResponse foundAccount = new AccountResponse() { account_id = account.AccountId, active = account.Active, username = account.UserName, admin_level = account.AdminLevel, created = new DateTime(account.CreatedTime) }; accounts.Add(foundAccount); foundAccount.characters = new List <Model.Character.CharacterResponse>(); foreach (var character in account.CharactersList) { var charResponse = new Model.Character.CharacterResponse() { account_id = account.AccountId, character_oid = character.ObjectId, firstname = character.FirstName, galaxy_id = character.GalaxyId, galaxy_name = character.GalaxyName, gender = character.Gender, race = character.Race, surname = character.SurName, }; if (character.HasBanned) { charResponse.ban_expiration = new DateTime(character.BanExpiration); charResponse.ban_reason = character.BanReason; charResponse.banned = character.Banned; } foundAccount.characters.Add(charResponse); } } return(accounts); } return(null); }
protected List <CharacterDetailsResponse> MakeRPCRequest(GetCharacterDetailsRequest req) { RcfProtoChannel channel = (RcfProtoChannel)RPCServiceStub.Channel; RPCServiceStub.GetCharacterDetails(null, req, null); GetCharacterDetailsResponse res = (GetCharacterDetailsResponse)channel.GetResponse(); if (res == null) { return(null); } List <CharacterDetailsResponse> characters = new List <CharacterDetailsResponse>(); foreach (var character in res.CharacterDetailsList) { var charDetails = new CharacterDetailsResponse() { account_id = character.AccountId, bank_credits = character.BankCredits, base_action = character.BaseAction, base_health = character.BaseHealth, base_mind = character.BaseMind, cash_credits = character.CashCredits, character_oid = character.ObjectId, firstname = character.FirstName, surname = character.SurName, }; if (character.InventoryItemsList.Count > 0) { charDetails.Inventory = character.InventoryItemsList .ToList() .ConvertAll <object>(cur => InventoryTransform.TransformInventoryItem(cur)) .ToList(); } if (character.StructuresList.Count > 0) { charDetails.Structures = character.StructuresList.ToList() .ConvertAll <StructureItem>(cur => StructureTransform.TransformStructure(cur)).ToList(); } if (character.HasBiography) { charDetails.biography = character.Biography; } if (character.HasTitle) { charDetails.title = character.Title; } if (character.HasRemainingPlots) { charDetails.remaining_lots = character.RemainingPlots; } if (character.HasMaximumimPlots) { charDetails.max_lots = character.MaximumimPlots; } if (character.HasAppearanceFile) { charDetails.appearance_file = character.AppearanceFile; } characters.Add(charDetails); } return(characters); }
static int Run(string[] args) { ParseCommandLine(args); // Locate path to certificates folder in distribution. string rootDir = DllPathResolver.FindDistributionRootDir(); string certsDir = Path.Combine(rootDir, "certs"); // Initialize RCFProto. RCFProto.Init(); // Build a search request. SearchRequest request = SearchRequest.CreateBuilder() .SetQuery("something to search for") .SetResultPerPage(10) .SetPageNumber(0) .Build(); // Call the server on each of its supported endpoints. List <Endpoint> endpoints = new List <Endpoint>(); endpoints.Add(new TcpEndpoint(50001)); endpoints.Add(new HttpEndpoint(50002)); endpoints.Add(new HttpsEndpoint(50003)); endpoints.Add(new Win32NamedPipeEndpoint("DemoServerPipe")); foreach (Endpoint endpoint in endpoints) { // Create channel. RcfProtoChannel channel = new RcfProtoChannel(endpoint); RcfProtoController rcfController = new RcfProtoController(); SearchService.Stub searchService = new SearchService.Stub(channel); // Set certificate validation callback, for SSL. channel.SetCertificateValidationCallback(OnValidateCertificate); { // Synchronous remote call. searchService.Search(null, request, null); SearchResponse response = (SearchResponse)channel.GetResponse(); } { // Asynchronous remote call. channel.SetAsynchronousRpcMode(true); Action <SearchResponse> done = delegate(SearchResponse response) { OnRpcDone(searchService, rcfController, request, response); }; searchService.Search(rcfController, request, done); while (gCallCompleted == false) { System.Threading.Thread.Sleep(500); } } } { // Create TCP channel. RcfProtoChannel channel = new RcfProtoChannel(endpoints[0]); RcfProtoController rcfController = new RcfProtoController(); SearchService.Stub searchService = new SearchService.Stub(channel); // Enable compression (requires zlib to be installed). //channel.SetEnableCompression(true); // Custom connection timeout (10s). channel.SetConnectTimeoutMs(10 * 1000); // Custom remote call timeout (60s). channel.SetRemoteCallTimeoutMs(60 * 1000); // Enable NTLM authentication and encryption. channel.SetTransportProtocol(TransportProtocol.Ntlm); // The channel will pick up the credentials of the user running the // program. Alternatively, we can set the credentials explicitly: //channel.setUsername("MyDomain\\MyUsername"); //channel.setPassword("MyPassword"); searchService.Search(null, request, null); SearchResponse response = (SearchResponse)channel.GetResponse(); // Enable SSL, with custom certificate validation callback. channel.SetTransportProtocol(TransportProtocol.Ssl); channel.SetCertificateValidationCallback(OnValidateCertificate); searchService.Search(null, request, null); response = (SearchResponse)channel.GetResponse(); // Enable SSL, with validation against Windows certificate root store. Requires Schannel. string certPath = Path.Combine(certsDir, "caCertA.p12"); // Open CA certificate. PfxCertificate caCert = new PfxCertificate(certPath, "", "RCF CA A"); // Add it to the root store of the local machine. caCert.AddToStore(Win32CertificateLocation.LocalMachine, Win32CertificateStore.Root); channel.SetEnableSchannelCertificateValidation("localhost"); channel.SetSslImplementation(SslImplementation.Schannel); // Disconnect so SSL handshake takes place again. channel.Disconnect(); searchService.Search(null, request, null); response = (SearchResponse)channel.GetResponse(); } return(0); }