Exemplo n.º 1
0
        private void ExtendedEventsReader_OnReadEvent(ExtendedEventsReader sender, OnReadEventArgs args)
        {
            if (sender.CurrentRow == null)
            {
                return;
            }

            var fileInfo  = new FileInfo(sender.CurrentFile);
            var eventData = new XEventData(fileInfo.Name, sender.CurrentFileEventNumber, args.EventData);

            _dataToSend.Add(eventData);

            if (_dataToSend.Count >= _portionSize)
            {
                SendDataCurrentPortion(sender).Wait();
            }
        }
Exemplo n.º 2
0
        private void onRead(object sender, OnReadEventArgs e)
        {
            string type = e.Obj.GetType().ToString();

            switch (type)
            {
            case "Facesketball.NetworkWindowInformation":
                NetworkWindowInformation tempNetInfo = (NetworkWindowInformation)e.Obj;
                tempNetInfo.windowRect.Width  /= 10;
                tempNetInfo.windowRect.Height /= 10;
                clientWindows.Add(tempNetInfo);

                /*for(int i = 0; i < clientWindows.Count - 1; i++)
                 * {
                 *  //Scoot newest window over by the cumulative width of the rest of the client windows
                 *  clientWindows[clientWindows.Count - 1].windowRect.X += clientWindows[i].windowRect.Width;
                 * }*/

                //Just kidding. Stick it to the right side of the last window (and I thought I was so clever)

                if (clientWindows.Count == 1)
                {
                    ClientControllingBall    = -1;
                    serverBall.FindNewScreen = true;
                }
                else
                {
                    clientWindows[clientWindows.Count - 1].windowRect.X += clientWindows[clientWindows.Count - 2].windowRect.Right + 4;     //Hardcoded
                }
                break;

            case "Facesketball.Ball":
                serverBall             = (Ball)e.Obj;
                serverBall.Position   *= .1f;
                serverBall.Speed      *= .1f;
                serverBall.Direction  *= .1f;
                serverBall.Position.X += clientWindows[e.ClientID].windowRect.Left;
                serverBall.Position.Y += clientWindows[e.ClientID].windowRect.Top;
                break;

            default:
                break;
            }
        }
Exemplo n.º 3
0
        private void onRead(IAsyncResult ar)
        {
            try
            {
                OnReadEventArgs eA         = new OnReadEventArgs();
                ClientReadInfo  readObject = (ClientReadInfo)ar.AsyncState;

                eA.Obj = Serializer.Serializer.DeserializeByteArray(readObject.Data);

                m_reading = false;

                m_stream.EndRead(ar);
                onReadUserCallback.Invoke(this, eA);
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Exemplo n.º 4
0
        private void onRead(object sender, OnReadEventArgs e)
        {
            string type = e.Obj.GetType().ToString();

            switch (type)
            {
            case "Facesketball.Ball":
                Ball serverBall = ((Ball)e.Obj);
                Bball.Location    = serverBall.Position;
                Bball.Direction   = serverBall.Direction;
                Bball.Speed       = serverBall.Speed;
                Bball.IsOffScreen = false;
                Bball.GravityDir  = serverBall.GravityDirection;
                break;

            default:
                break;
            }
        }
Exemplo n.º 5
0
        private void onRead(IAsyncResult ar)
        {
            //WTF: Okay, so this try and catch was falling into the catch and throwing an index
            //out of bounds exception WHICH IT'S CLEARLY NOT because the function works fine
            //without the try and catch, and it didn't even after I added the "if" statement
            //below (labeled by a comment saying "//TEST"), which clearly prevents ANY sort of
            //out of bounds id.


            //try
            //{
            //Cast ar.StupidName as our ReadInfo so we can get the idea and object data
            OnReadEventArgs eA         = new OnReadEventArgs();
            ServerReadInfo  readObject = (ServerReadInfo)ar.AsyncState;

            int id = readObject.Id;

            //TEST
            if (id > m_clients.Count - 1 || id < 0)
            {
                return;
            }

            //Deserialize the byte array to create an object.  We're gonna store the object
            //in our OnReadEventArgs along with the id to send back to the original caller.
            eA.Obj      = Serializer.Serializer.DeserializeByteArray(readObject.Data);
            eA.ClientID = id;

            //Done reading.  The position of this assignment is actually very important in
            //the async world, apparently.
            m_clients[id].Reading = false;
            m_clients[id].Stream.EndRead(ar);

            //Invoke the User's callback
            onReadUserCallback.Invoke(this, eA);
            //}

            /*catch (Exception e)
             * {
             *  throw e;
             * }*/
        }
Exemplo n.º 6
0
 private void RaiseOnRead(OnReadEventArgs args)
 {
     OnReadEvent?.Invoke(this, args);
 }