示例#1
0
        public void Initialize(LiteCollection <Screen> screenCollection)
        {
            if (this.IsInitialized)
            {
                return;
            }

            this.screenCollection   = screenCollection;
            this.screenStateManager = new ScreenStateManager();

            this.Play          = new NetworkMethod <PlayEvent>(Events.Play, this.OnPlay);
            this.Pause         = new NetworkMethod <string>(Events.Pause, this.OnPause);
            this.Stop          = new NetworkMethod <string>(Events.Stop, this.OnStop);
            this.Resume        = new NetworkMethod <string>(Events.Resume, this.OnResume);
            this.Seek          = new NetworkMethod <string, float>(Events.Seek, this.OnSeek);
            this.Duration      = new NetworkMethod <string, float>(Events.UpdateStateDuration, this.OnUpdateDuration);
            this.PlaybackEnded = new NetworkMethod <string>(Events.PlaybackEnded, this.OnPlaybackEnded);

            BaseServer.Self.AddExport(Events.Play, new Action <string, string>(this.OnPlay));
            BaseServer.Self.AddExport(Events.Pause, new Action <string>(this.OnPause));
            BaseServer.Self.AddExport(Events.Stop, new Action <string>(this.OnStop));
            BaseServer.Self.AddExport(Events.Resume, new Action <string>(this.OnResume));
            BaseServer.Self.AddExport(Events.Seek, new Action <string, float>(this.OnSeek));

            this.IsInitialized = true;
        }
        protected void Create_Standard_Patrol(int End_A, int End_B)
        {
            List <int> Route = NetworkMethod.Dijkstrafy_Routes(map, new List <int>()
            {
                End_A, End_B
            });

            if (Route.Count > 2)
            {
                List <int> Way_Back = new List <int>();
                for (int I = Route.Count - 2; I >= 1; I--)//cuts the first and last point - these would just be repeats.
                {
                    Way_Back.Add(Route[I]);
                }
                Route.AddRange(Way_Back);
            }

            AIMoveManager.Instance.RemoveFromRR(Route);
            Default_Route_Waypoints = Create_New_Waypoint_Set(Route);

            if (Default_Route_Waypoints.Count == Route.Count)
            {
                Default_Route_Waypoint_Rooms = Route;
            }
            else
            {
                Default_Route_Waypoint_Rooms = new List <int>();
                for (int I = 0; I < Default_Route_Waypoints.Count; I++)
                {
                    Default_Route_Waypoint_Rooms.Add(RectMethod.FindWhatRoomLocationIsIn(Default_Route_Waypoints[I], map, out bool VOID));
                }
            }
            NextWaypointNum = AssignStartingWaypoint();
        }
    protected override void OnCreateManager(int capacity)
    {
        networkFactory = new NetworkFactory(EntityManager);
        var types = reflectionUtility.ComponentTypes;
        var type  = typeof(NetworkReceiveSystem);

        for (int i = 0; i < types.Length; i++)
        {
            var addMethod = GetMethod(types[i], type, "AddComponent");
            var addInfo   = new NetworkMethodInfo <NetworkReceiveSystem, Entity, List <ComponentField> >(addMethod);
            AddComponentsMethods.Add(types[i], addInfo);

            var removeMethod = GetMethod(types[i], type, "RemoveComponent");
            var removeInfo   = new NetworkMethodInfo <NetworkReceiveSystem, Entity>(removeMethod);
            RemoveComponentsMethods.Add(types[i], removeInfo);

            var setMethod = GetMethod(types[i], type, "SetComponent");
            var setInfo   = new NetworkMethodInfo <NetworkReceiveSystem, Entity, List <ComponentField> >(setMethod);
            SetComponentsMethods.Add(types[i], setInfo);

            var updateMethod = GetMethod(types[i], type, "UpdateComponent");
            var updateInfo   = new NetworkMethod <NetworkReceiveSystem>(updateMethod);
            UpdateComponentsMethods.Add(updateInfo);

            var destroyMethod = GetMethod(types[i], type, "RemoveComponentOnDestroyEntity");
            var destroyInfo   = new NetworkMethodInfo <NetworkReceiveSystem, Entity>(destroyMethod);
            RemoveComponentOnDestroyEntityMethods.Add(destroyInfo);
        }
        messageSerializer = new NetworkMessageSerializer <SyncEntities>();
    }
示例#4
0
        public static async Task <string> Send(string url, string data = null, NetworkMethod method = NetworkMethod.POST)
        {
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            request.Method = Methods.First(x => x.Key == method).Value;

            //data = "{\"email\": \"[email protected]\" , \"api_key\": \"d0b98631-c559-11e8-b088-0cc47ae3c526\" }";

            request.ContentType = "application/json";
            request.Accept      = "application/json";

            request.Headers["X-My-Custom-Header"] = "the-value";

            //request.ContentLength = byteArray.Length;

            using (var streamWriter = new StreamWriter(request.GetRequestStream()))
            {
                streamWriter.Write(data);
                streamWriter.Flush();
            }

            var httpResponse = await request.GetResponseAsync();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
                return(result);
            }
        }
示例#5
0
        public void Initialize()
        {
            if (this.IsInitialized)
            {
                return;
            }

            this.Play          = new NetworkMethod <PlayEvent>(Events.Play, this.OnPlay);
            this.Pause         = new NetworkMethod <string>(Events.Pause, this.OnPause);
            this.Resume        = new NetworkMethod <string>(Events.Resume, this.OnResume);
            this.Stop          = new NetworkMethod <string>(Events.Stop, this.OnStop);
            this.Seek          = new NetworkMethod <string, float>(Events.Seek, this.OnSeek);
            this.StateDuration = new NetworkMethod <string, float>(
                Events.UpdateStateDuration,
                this.OnUpdateStateDuration);
            this.EditScreen    = new NetworkMethod <Screen>(Events.EditScreen, this.OnEditScreen);
            this.DeleteScreen  = new NetworkMethod <string>(Events.DeleteScreen, this.OnDeleteScreen);
            this.PlaybackEnded = new NetworkMethod <string>(Events.PlaybackEnded, this.OnPlaybackEnded);

            ClientScript.Self.RegisterNuiCallback(Events.Play, this.OnPlay);
            ClientScript.Self.RegisterNuiCallback(Events.Pause, this.OnPause);
            ClientScript.Self.RegisterNuiCallback(Events.Resume, this.OnResume);
            ClientScript.Self.RegisterNuiCallback(Events.Stop, this.OnStop);
            ClientScript.Self.RegisterNuiCallback(Events.Seek, this.OnSeek);

            ClientScript.Self.RegisterNuiCallback(Events.UpdateStateDuration, this.OnUpdateStateDuration);
            ClientScript.Self.RegisterNuiCallback(Events.RequestState, this.OnRequestState);
            ClientScript.Self.RegisterNuiCallback(Events.PlaybackEnded, this.OnPlaybackEnded);

            this.IsInitialized = true;
        }
        private ScaleformRendererPool()
        {
            this.getMaxActiveScaleforms = new NetworkMethod <int>(
                Events.GetMaxActiveScaleforms,
                this.OnGetMaxActiveScaleforms);

            this.getMaxActiveScaleforms.Invoke(0);
        }
        protected void Create_Long_Circuit_Patrol(List <int> Visits)//doesn't have to be sorted
        {
            List <int> Route = NetworkMethod.Dijkstrafy_Routes(map, Visits);

            AIMoveManager.Instance.RemoveFromRR(Route);
            Default_Route_Waypoints = Create_New_Waypoint_Set(Route);

            if (Default_Route_Waypoints.Count == Route.Count)
            {
                Default_Route_Waypoint_Rooms = Route;
            }
            else
            {
                Default_Route_Waypoint_Rooms = new List <int>();
                for (int I = 0; I < Default_Route_Waypoints.Count; I++)
                {
                    Default_Route_Waypoint_Rooms.Add(RectMethod.FindWhatRoomLocationIsIn(Default_Route_Waypoints[I], map, out bool VOID));
                }
            }
            NextWaypointNum = AssignStartingWaypoint();
        }
示例#8
0
        public static HttpWebRequest GenerateRequest(string uri, string content, NetworkMethod method, string login, string password, bool allowAutoRedirect)
        {
            if (uri == null)
            {
                throw new ArgumentNullException("uri");
            }
            // Create a request using a URL that can receive a post.
            HttpWebRequest request = (HttpWebRequest)HttpWebRequest.Create(uri);

            // Set the Method property of the request to POST.
            request.Method = "Get";
            // Set cookie container to maintain cookies
            request.CookieContainer   = cookies;
            request.AllowAutoRedirect = allowAutoRedirect;
            // If login is empty use defaul credentials
            if (string.IsNullOrEmpty(login))
            {
                request.Credentials = CredentialCache.DefaultNetworkCredentials;
            }
            else
            {
                request.Credentials = new NetworkCredential(login, password);
            }
            if (method == NetworkMethod.Post)
            {
                // Convert POST data to a byte array.
                byte[] byteArray = Encoding.UTF8.GetBytes(content);
                // Set the ContentType property of the WebRequest.
                request.ContentType = "application/x-www-form-urlencoded";
                // Set the ContentLength property of the WebRequest.
                request.ContentLength = byteArray.Length;
                // Get the request stream.
                Stream dataStream = request.GetRequestStream();
                // Write the data to the request stream.
                dataStream.Write(byteArray, 0, byteArray.Length);
                // Close the Stream object.
                dataStream.Close();
            }
            return(request);
        }
示例#9
0
        private async Task OnFirstTick()
        {
            this.Tick -= this.OnFirstTick;

            this.ReadConfiguration();

            this.OpenDatabase();

            // Create Example Screen if Database is empty
            this.PopulateDatabaseIfEmpty();

            this.CalculateMaxActiveScaleforms();

            this.playbackManager.Initialize(this.screenCollection);
            this.storageManager.Initialize(this.screenCollection);

            this.getMaxActiveScaleforms = new NetworkMethod <int>(
                Events.GetMaxActiveScaleforms,
                this.OnGetMaxActiveScaleforms);

            await UpdateChecker.CheckForNewerVersion();

            await Delay(0);
        }
示例#10
0
        public ScreenStateManager()
        {
            this.duiState = new NetworkMethod <Guid, List <DuiState> >(Events.DuiState, this.OnDuiState);

            BaseServer.Self.AddExport(Events.DuiState, new Func <string>(this.OnDuiState));
        }
示例#11
0
        public static async Task <string> SendAlfaCRM(string url, string token, string data, NetworkMethod method)
        {
            //string url = auth.HostName + "/v2api/1/customer/index";
            HttpWebRequest request = (HttpWebRequest)WebRequest.Create(url);

            request.Method = Methods.First(x => x.Key == method).Value;


            request.ContentType = "application/json";
            request.Accept      = "application/json";

            request.Headers["X-ALFACRM-TOKEN"] = token;

            //request.ContentLength = byteArray.Length;

            using (var streamWriter = new StreamWriter(request.GetRequestStream()))
            {
                streamWriter.Write(data);
                streamWriter.Flush();
            }

            var httpResponse = await request.GetResponseAsync();

            using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
            {
                var result = streamReader.ReadToEnd();
                return(result);
            }
        }
 public DuiStateHelper()
 {
     this.duiStateMethod = new NetworkMethod <Guid, List <DuiState> >(Events.DuiState, this.OnDuiState);
 }