private Revision retrieveServerMaster()
        {
            commandTransporter.Send(new BytePacket((byte)SyncerCommands.RequestMaster));
            var p = revisionTransporter.Receive();

            return(retrieveRevision(p.Guid));
        }
Esempio n. 2
0
 private void receiveTimeJob()
 {
     // This is an old method. You can have this functionality directly now with the transporters.
     for (; ;)
     {
         var p = timeTransport.Receive();
         //Not sure this is thread safe but probably ok
         totalTime  = p.TotalTime;
         tickNumber = p.TickNumber;
     }
 }
        public void Update(float elapsed)
        {
            while (updateTransporter.PacketAvailable)
            {
                var p = updateTransporter.Receive();


                var obj = findObject(p.ID);
                if (obj == null)
                {
                    obj = createObject(p.ID);
                }

                worldObjectFactory.ApplyUpdatePacket(obj, p);
            }
            while (deleteTransporter.PacketAvailable)
            {
                var p = updateTransporter.Receive();
                removeObject(p.ID);
            }
        }
Esempio n. 4
0
 private void receiveDeltaJob()
 {
     // This is an old method. You can have this functionality directly now with the transporters.
     for (; ;)
     {
         var p = deltaTransport.Receive();
         if (p.Data == null)
         {
             throw new InvalidOperationException("Can't be null!!");
         }
         lock (deltaPackets)
             deltaPackets.Enqueue(p.Data);
     }
 }
        private void receiveJob()
        {
            for (; ;)
            {
                lock (receiveLock)
                {
                    while (fileReceived)
                    {
                        Monitor.Wait(receiveLock);
                    }


                    var start = startTransporter.Receive();
                    receivingFilePath = generateTemporaryFilename();

                    using (
                        receivingStream =
                            File.Open(receivingFilePath, FileMode.CreateNew, FileAccess.Write, FileShare.Delete))
                    {
                        for (; ;)
                        {
                            var part = partTransporter.Receive();

                            receivingStream.Write(part.Data, 0, part.Data.Length);

                            if (part.Canceled)
                            {
                                break;
                            }
                            if (!part.Complete)
                            {
                                continue;
                            }

                            var end = endTransporter.Receive();
                            receivedPacket = end;

                            fileReceived = true;
                            Monitor.Pulse(receiveLock);
                            break;
                        }
                    }
                }
            }
        }
        public void ForwardReceivedInputs()
        {
            while (transporter.PacketAvailable)
            {
                var p = transporter.Receive();
                switch (p.Method)
                {
                case "OnSave":
                    handler.OnSave();
                    break;

                case "OnNextTool":
                    handler.OnNextTool();
                    break;

                case "OnPreviousTool":
                    handler.OnPreviousTool();
                    break;

                case "OnLeftClick":
                    handler.OnLeftClick(world.GetVoxel(new Point2(p.VoxelCoordX, p.VoxelCoordY)));
                    break;

                case "OnRightClick":
                    handler.OnRightClick(world.GetVoxel(new Point2(p.VoxelCoordX, p.VoxelCoordY)));
                    break;

                case "OnKeyPressed":
                    handler.OnKeyPressed(world.GetVoxel(new Point2(p.VoxelCoordX, p.VoxelCoordY)), (Key)p.Key);
                    break;

                default:
                    throw new InvalidOperationException("Unknown input method: " + p.Method);
                }
            }
        }