public PHPC(Uri URL, bool UseAuth, string Username = "******", string Password = "******") { this.URL = URL; NameValueCollection data = new NameValueCollection(); data = DataInjector.Foundation(data); string str = WebSocket.SendRequest(this.URL, data); if (str.ToLower().Contains("request;success")) { if (UseAuth) { throw new Exception("Authorization is not required for this server"); } this.UseAuth = UseAuth; this.Username = Username; this.Password = Password; } else { if (!str.ToLower().Contains("request;failure")) { throw new Exception($"Server returned an unknown response {str}"); } if (str.ToLower().Contains("(error0@1) = auth required")) { if (!UseAuth) { throw new Exception("Authorization is required for this server"); } data = DataInjector.AddAuth(data, Username, Password); str = WebSocket.SendRequest(this.URL, data); if (str.ToLower().Contains("request;failure")) { if (str.ToLower().Contains("(error1@1)")) { throw new Exception("Authorization failure, Incorrect username or password"); } throw new Exception($"Server returned an unknown response {str}"); } if (str.ToLower().Contains("request;success")) { this.UseAuth = UseAuth; this.Username = Username; this.Password = Password; } } else { if (str.ToLower().Contains("(error 2@2)")) { throw new Exception("The server does not support this client's version"); } throw new Exception($"Server returned an unknown response {str}"); } } }
protected void DisposeChildToPool(DataInjector dataInjector) { if (dataInjector == null) { return; } objectsReturningToPool.Add(dataInjector); dataInjector?.Dispose(() => ReturnToPool(dataInjector)); }
protected void ReturnToPool(DataInjector dataInjector) { if (objectsReturningToPool.Contains(dataInjector)) { objectsReturningToPool.Remove(dataInjector); } dataInjector.gameObject.SetActive(false); dataInjector.gameObject.name = string.Format("{0} (Pooled)", childPrefab.Value.name); pooledObjects.Add(dataInjector); dataInjector.transform.SetAsLastSibling(); }
public string SendRequest(Vodka Data) { NameValueCollection data = new NameValueCollection(); data = DataInjector.Foundation(data); if (this.UseAuth) { data = DataInjector.AddAuth(data, this.Username, this.Password); } data.Add("Request-Data", Vodka.Encode(Data)); return(WebSocket.SendRequest(this.URL, data)); }
protected override void ApplySet() { if (childPrefab.Value == null || dataBundle.Value == null) { return; } if (spawnedChild == null) { spawnedChild = Instantiate(childPrefab.Value, transform); } spawnedChild.name = string.Format("{0} ({1})", childPrefab.Value.name, dataBundle.Value.id); spawnedChild.Inject(dataBundle); }
protected DataInjector GetFromPool() { DataInjector toReturn = null; if (pooledObjects.Count > 0) { toReturn = pooledObjects[0]; pooledObjects.RemoveAt(0); toReturn.gameObject.SetActive(true); } else { toReturn = Instantiate(childPrefab.Value, transform); } return(toReturn); }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddMvc((options) => { options.Filters.Add(typeof(ValidationActionFilter)); }) .AddFluentValidation(fvc => fvc.RegisterValidatorsFromAssemblyContaining <BusinessInjector>()) .AddJsonOptions(options => { options.SerializerSettings.NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore; options.SerializerSettings.Formatting = Newtonsoft.Json.Formatting.Indented; }); //Register Services BusinessInjector.RegisterServices(Configuration, services); DataInjector.RegisterServices(Configuration, services); }
protected List <DataInjectionReceiver> GetInjectionReceivers(GameObject obj) { List <DataInjectionReceiver> dataInjectionReceivers = new List <DataInjectionReceiver>(); dataInjectionReceivers.AddRange(obj.GetComponents <DataInjectionReceiver>()); foreach (Transform child in obj.transform) { DataInjector injector = child.GetComponent <DataInjector>(); if (injector) { dataInjectionReceivers.Add(injector); } else { dataInjectionReceivers.AddRange(GetInjectionReceivers(child.gameObject)); } } dataInjectionReceivers.Remove(this); return(dataInjectionReceivers); }
private void Awake() { dataInjector = GetComponent <DataInjector>(); nodeGrid = FindObjectOfType <NodeGrid>(); }