ReadInt32() public method

Reads a 32 bit signed integer written using Write(Int32)
public ReadInt32 ( ) : Int32
return System.Int32
コード例 #1
0
 public void Decode(NetIncomingMessage im)
 {
     Shots = im.ReadInt32();
        Hits = im.ReadInt32();
        Misses = im.ReadInt32();
        ShipsKilled = im.ReadInt32();
 }
コード例 #2
0
 public void R(NetIncomingMessage im)
 {
     Uid         = im.ReadUInt32();
     X           = im.ReadInt32();
     Y           = im.ReadInt32();
     SpriteId    = im.ReadUInt32();
 }
コード例 #3
0
 public void Decode(NetIncomingMessage im)
 {
     this.Value = (ResultOfAttack) im.ReadInt32();
        this.Text = im.ReadString();
        this.Row = im.ReadInt32();
        this.Col = im.ReadInt32();
 }
コード例 #4
0
 public override void ReadPayload(NetIncomingMessage message)
 {
     base.ReadPayload(message);
     Image = message.ReadBytes(message.ReadInt32());
     Number = message.ReadUInt32();
     SendIndex = message.ReadInt32();
 }
コード例 #5
0
 public void Decode(NetIncomingMessage im)
 {
     this.MessageTime = im.ReadDouble();
     this.Id = im.ReadInt32();
     this.OldPosition = im.ReadInt32();
     this.NewPosition = im.ReadInt32();
 }
コード例 #6
0
 public override void ReadPayload(NetIncomingMessage message)
 {
     base.ReadPayload(message);
     Region = new Rectangle(message.ReadInt32(), message.ReadInt32(), message.ReadInt32(), message.ReadInt32());
     Number = message.ReadUInt32();
     FinalLength = message.ReadInt32();
 }
コード例 #7
0
ファイル: MapManager.cs プロジェクト: Gartley/ss13remake
        public bool LoadTileMap(NetIncomingMessage message)
        {
            int _mapWidth = message.ReadInt32();
            int _mapHeight = message.ReadInt32();


            _groundArray = new QuadTree<Tile>(new SizeF(2*TileSpacing, 2*TileSpacing), 4);
            _wallArray = new QuadTree<Tile>(new SizeF(2 * TileSpacing, 2 * TileSpacing), 4);

            while (message.PositionInBytes < message.LengthBytes)
            {
                float posX = message.ReadFloat();
                float posY = message.ReadFloat();
                byte index = message.ReadByte();
                var state = (TileState)message.ReadByte();
                string name = GetTileString(index);
                Direction dir = Direction.North;
                if (name == "Wall")
                {
                    dir = (Direction)message.ReadByte();
                }
                Tile newTile = GenerateNewTile(GetTileString(index), state, new Vector2D(posX, posY), dir);
                AddTile(newTile);
            }

            foreach (Wall w in GetAllWallIn(new RectangleF(0, 0, _mapWidth * TileSpacing, _mapHeight * TileSpacing)))
            {
                w.SetSprite();
            }

            _loaded = true;
            return true;
        }
コード例 #8
0
 public void Decode(NetIncomingMessage im)
 {
     this.MessageTime = im.ReadDouble();
     this.Id = im.ReadInt32();
     this.EquipmentPosition = im.ReadInt32();
     this.InventoryPosition = im.ReadInt32();
 }
 public HealthTransferableData(NetIncomingMessage message)
 {
     SessionID = message.ReadInt64();
     ID = message.ReadInt32();
     IsValid = message.ReadBoolean();
     PlayerIndex = message.ReadInt32();
     Value = message.ReadFloat();
 }
コード例 #10
0
ファイル: Msg_AgarMarkListPack.cs プロジェクト: xxy1991/cozy
 public void R(NetIncomingMessage im)
 {
     int Count = im.ReadInt32();
     for(int i = 0; i < Count; ++i)
     {
         uint id = im.ReadUInt32();
         int mark = im.ReadInt32();
         MarkList.Add(new KeyValuePair<uint, int>(id, mark));
     }
 }
コード例 #11
0
 /// <summary>
 /// Handles an incoming entity component message
 /// </summary>
 /// <param name="message">Raw network message</param>
 /// <returns>An IncomingEntityComponentMessage object</returns>
 public IncomingEntityComponentMessage HandleEntityComponentNetworkMessage(NetIncomingMessage message)
 {
     var componentFamily = (ComponentFamily) message.ReadByte();
     var messageParams = new List<object>();
     while (message.Position < message.LengthBits)
     {
         switch ((NetworkDataType) message.ReadByte())
         {
             case NetworkDataType.d_enum:
                 messageParams.Add(message.ReadInt32());
                 break;
             case NetworkDataType.d_bool:
                 messageParams.Add(message.ReadBoolean());
                 break;
             case NetworkDataType.d_byte:
                 messageParams.Add(message.ReadByte());
                 break;
             case NetworkDataType.d_sbyte:
                 messageParams.Add(message.ReadSByte());
                 break;
             case NetworkDataType.d_ushort:
                 messageParams.Add(message.ReadUInt16());
                 break;
             case NetworkDataType.d_short:
                 messageParams.Add(message.ReadInt16());
                 break;
             case NetworkDataType.d_int:
                 messageParams.Add(message.ReadInt32());
                 break;
             case NetworkDataType.d_uint:
                 messageParams.Add(message.ReadUInt32());
                 break;
             case NetworkDataType.d_ulong:
                 messageParams.Add(message.ReadUInt64());
                 break;
             case NetworkDataType.d_long:
                 messageParams.Add(message.ReadInt64());
                 break;
             case NetworkDataType.d_float:
                 messageParams.Add(message.ReadFloat());
                 break;
             case NetworkDataType.d_double:
                 messageParams.Add(message.ReadDouble());
                 break;
             case NetworkDataType.d_string:
                 messageParams.Add(message.ReadString());
                 break;
             case NetworkDataType.d_byteArray:
                 int length = message.ReadInt32();
                 messageParams.Add(message.ReadBytes(length));
                 break;
         }
     }
     return new IncomingEntityComponentMessage(componentFamily, messageParams);
 }
コード例 #12
0
        public void PopulateFromMsg(NetIncomingMessage msg)
        {
            m_serverName = msg.ReadString();
            m_serverType = (NetServerType)msg.ReadByte();
            m_serverInternalAdress = msg.ReadIPEndPoint();
            m_serverExternalAdress = msg.SenderEndPoint;
            m_currentNbPlayers = msg.ReadInt32();
            m_maxPlayers = msg.ReadInt32();
            m_NATtoken = msg.ReadString();

            m_lastContact = DateTime.Now;
        }
コード例 #13
0
        public void Decode(NetIncomingMessage im)
        {
            this.Id = im.ReadInt32();
            this.MessageTime = im.ReadDouble();

            //this.Region = Utility.Serializer.DeserializeObjectFromString<Model.Map.Region.Region>(im.ReadString());
            //this.Region.Parent = Model.Map.World.World.world;

            this.Position = im.ReadVector3();

            this.RegionEnum = (Model.Map.Region.RegionEnum)im.ReadInt32();
        }
コード例 #14
0
ファイル: Msg_AgarFixBallPack.cs プロジェクト: xxy1991/cozy
 public void R(NetIncomingMessage im)
 {
     int Count = im.ReadInt32();
     for(int i = 0; i < Count; ++i)
     {
         uint uid = im.ReadUInt32();
         float x = im.ReadFloat();
         float y = im.ReadFloat();
         int r = im.ReadInt32();
         uint color = im.ReadUInt32();
         FixedList.Add(Tuple.Create<uint, float, float, int, uint>(uid, x, y, r, color));
     }
 }
コード例 #15
0
ファイル: Msg_AgarPlayInfoPack.cs プロジェクト: xxy1991/cozy
 public void R(NetIncomingMessage im)
 {
     int Count = im.ReadInt32();
     for (int i = 0; i < Count; ++i)
     {
         uint uid    = im.ReadUInt32();
         float x     = im.ReadFloat();
         float y     = im.ReadFloat();
         int r     = im.ReadInt32();
         uint color  = im.ReadUInt32();
         string name = im.ReadString();
         PLayerList.Add(Tuple.Create<uint, float, float, int, uint, string>(uid, x, y, r, color, name));
     }
 }
コード例 #16
0
ファイル: Package.cs プロジェクト: andva/Eulerian-ShootEmUp
 public static Player MsgToPlayer(NetIncomingMessage im, GraphicsDevice device)
 {
     bool alive = im.ReadBoolean();
     float xp = im.ReadFloat();
     float yp = im.ReadFloat();
     float zp = im.ReadFloat();
     Int32 id = im.ReadInt32();
     float xr = im.ReadFloat();
     xr = im.ReadFloat();
     Int32 mo = im.ReadInt32();
     Player d = new Player(xp, yp, zp, id, mo, device);
     Globals.player = d;
     return d;
 }
コード例 #17
0
        public void deserialize(NetIncomingMessage inMsg)
        {
            targetFrame = inMsg.ReadUInt32();
            orderList.Capacity = inMsg.ReadInt32();

            for (int i = 0; i < orderList.Capacity; i++)
            {
                int orderID = inMsg.ReadInt32();
                Order newOrder = (Order)Activator.CreateInstance(OrderRegister.instance.idToOrder(orderID));
                newOrder.deserialize(inMsg);

                orderList.Add(newOrder);
            }
        }
コード例 #18
0
        public override void Read(NetIncomingMessage msg)
        {
            int count = msg.ReadInt32();
            for(int i = 0; i < count; ++i)
            {
                ushort uid = msg.ReadUInt16();
                List<string> cards = new List<string>();

                int cardCount = msg.ReadInt32();
                for(int j = 0; j < cardCount; ++j)
                    cards.Add(msg.ReadString());

                Options.Add(new Tuple<ushort, List<string>>(uid, cards));
            }
        }
コード例 #19
0
ファイル: Msg_AgarSelf.cs プロジェクト: xxy1991/cozy
 public void R(NetIncomingMessage im)
 {
     Operat      = im.ReadByte();
     if(Operat == GroupUp)
     {
         Radius  = im.ReadInt32();
     }
     else if(Operat == Born)
     {
         X = im.ReadFloat();
         Y = im.ReadFloat();
         Radius = im.ReadInt32();
         Color = im.ReadUInt32();
     }
 }
コード例 #20
0
ファイル: TerrainManager.cs プロジェクト: fusspawn/sobriety
        public void LoadTerrainFromNetwork(NetIncomingMessage MapDataMessage)
        {
            TerrainTiles = new SpriteSheet(GameClient.ContentManager.Load<Texture2D>("Terrain2"), 40, 40);
            int TerrainCount = MapDataMessage.ReadInt32();
            for (int i = 0; i < TerrainCount; i++) {
                Terrain.Add(new TerrainTile()  {
                    X = MapDataMessage.ReadInt32(),
                    Y = MapDataMessage.ReadInt32(),
                    TileID = MapDataMessage.ReadByte(),
                    Passable = MapDataMessage.ReadBoolean(),
                });
            }

            Console.WriteLine("TerrainData Loaded");
        }
コード例 #21
0
 public void Decode(NetIncomingMessage im)
 {
     this.Id = im.ReadInt32();
     this.MessageTime = im.ReadDouble();
     this.Health = im.ReadFloat();
     this.MaxHealth = im.ReadFloat();
 }
コード例 #22
0
        public override void onclientrecieve(NetIncomingMessage message)
        {
            int matrixid = message.ReadInt32();
            string name = message.ReadString();

            base.onclientrecieve(message);
        }
コード例 #23
0
ファイル: Packet.cs プロジェクト: CyrilPaulus/2dThing
 public static Packet decode(ref NetIncomingMessage msg)
 {
     Packet p = new Packet (0);
     p.type = msg.ReadByte ();
     p.clientId = msg.ReadInt32 ();
     return p;
 }
コード例 #24
0
ファイル: Attribute.cs プロジェクト: fusspawn/sobriety
 private void ReadData(AttributeTypeID Type, NetIncomingMessage Message)
 {
     switch(Type) {
         case AttributeTypeID.Float:
             Data = Message.ReadFloat();
             break;
         case AttributeTypeID.Int:
             Data = Message.ReadInt32();
             break;
         case AttributeTypeID.List:
             Console.WriteLine("AttributeSystem: List<> Type not supported on network sync");
             break;
         case AttributeTypeID.Long:
             Data = Message.ReadInt64();
             break;
         case AttributeTypeID.Rectangle:
             Data = Message.ReadRectangle();
             break;
         case AttributeTypeID.String:
             Data = Message.ReadString();
             break;
         case AttributeTypeID.Vector2:
             Data = Message.ReadVector2();
             break;
         case AttributeTypeID.Bool:
             Data = Message.ReadBoolean();
             break;
         default:
             Console.WriteLine("Invalid Attribute Type: {0}", Type.ToString());
             break;
     }
 }
コード例 #25
0
 protected override void ReadData(NetIncomingMessage Message)
 {
     texture.Read(Message);
     int datalen = Message.ReadInt32();
     byte[] data = Message.ReadBytes(datalen);
     img = GetBitmap(data);
 }
コード例 #26
0
ファイル: Block.cs プロジェクト: CloneDeath/FantasyScape
 public void Read(NetIncomingMessage nim)
 {
     if (!Guid.TryParse(nim.ReadString(), out BlockTypeID)) {
         throw new Exception("Failed to read GUID");
     }
     Level = nim.ReadInt32();
 }
 public ClientDisconnectedTransferableData(NetIncomingMessage message)
 {
     SessionID = message.ReadInt64();
     ID = message.ReadInt32();
     IsValid = message.ReadBoolean();
     PlayerIndex = message.ReadInt16();
 }
コード例 #28
0
ファイル: Package.cs プロジェクト: andva/Eulerian-ShootEmUp
        public static void ToOtherPlayers(NetIncomingMessage im, OtherPlayer[] d)
        {
            bool alive = im.ReadBoolean();
            float xp = im.ReadFloat();
            float yp = im.ReadFloat();
            float zp = im.ReadFloat();
            Int32 id = im.ReadInt32();
            float xr = im.ReadFloat();
            float yr = im.ReadFloat();
            Int16 model = im.ReadInt16();
            if (d[id] == null)
            {
                d[id] = new OtherPlayer(xp, yp, zp, id, model, xr, yr);
            }
            d[id].model = model;
            d[id].xr = xr;
            d[id].yr = yr;

            if (!alive)
            {
                d[id].ChangeLifeStatus(false);
            }
            d[id].position = new Vector3(xp, yp, zp);
            d[id].boundingSphere.Center = new Vector3(d[id].position.X, d[id].position.Y + Constants.HEADMAX/2, d[id].position.Z);
        }
コード例 #29
0
 public override void Read(NetIncomingMessage msg)
 {
     Id = msg.ReadUInt16();
     int count = msg.ReadInt32();
     for(int i = 0; i < count; ++i)
         Cards.Add(msg.ReadString());
 }
コード例 #30
0
 public static new Packet FromNetBuffer(NetIncomingMessage incomingMessage)
 {
     var id = incomingMessage.ReadInt32();
     var type = (ContentType)incomingMessage.ReadByte();
     var packet = new ContentReleasePacket(type, id);
     return packet;
 }
コード例 #31
0
ファイル: INetSerializable.cs プロジェクト: Antaresgames/PNet
        /// <summary>
        /// Deserialize the array from the message
        /// </summary>
        /// <param name="message"></param>
        public void OnDeserialize(Lidgren.Network.NetIncomingMessage message)
        {
            var length = message.ReadInt32();

            items = new T[length];

            for (int i = 0; i < length; i++)
            {
                var t = new T();
                t.OnDeserialize(message);
                items[i] = t;
            }
        }
コード例 #32
0
        /// <summary>
        /// deserialize from the message
        /// </summary>
        /// <param name="message"></param>
        public void OnDeserialize(Lidgren.Network.NetIncomingMessage message)
        {
            var size = message.ReadInt32();

            dictionary = new Dictionary <T, U>(size);

            for (int i = 0; i < size; ++i)
            {
                var key   = message.Read <T>();
                var value = message.Read <U>();

                dictionary[key] = value;
            }
        }
コード例 #33
0
        // received a library message while Connected
        internal void ReceivedLibraryMessage(NetMessageType tp, int ptr, int payloadLength)
        {
            m_peer.VerifyNetworkThread();

            double now = NetTime.Now;

            switch (tp)
            {
            case NetMessageType.Connect:
                m_peer.LogDebug("Received handshake message (" + tp + ") despite connection being in place");
                break;

            case NetMessageType.ConnectResponse:
                // handshake message must have been lost
                HandleConnectResponse(now, tp, ptr, payloadLength);
                break;

            case NetMessageType.ConnectionEstablished:
                // do nothing, all's well
                break;

            case NetMessageType.LibraryError:
                m_peer.ThrowOrLog("LibraryError received by ReceivedLibraryMessage; this usually indicates a malformed message");
                break;

            case NetMessageType.Disconnect:
                NetIncomingMessage msg = m_peer.SetupReadHelperMessage(ptr, payloadLength);

                m_disconnectRequested  = true;
                m_disconnectMessage    = msg.ReadString();
                m_disconnectReqSendBye = false;
                //ExecuteDisconnect(msg.ReadString(), false);
                break;

            case NetMessageType.Acknowledge:
                for (int i = 0; i < payloadLength; i += 3)
                {
                    NetMessageType acktp = (NetMessageType)m_peer.m_receiveBuffer[ptr++];                             // netmessagetype
                    int            seqNr = m_peer.m_receiveBuffer[ptr++];
                    seqNr |= (m_peer.m_receiveBuffer[ptr++] << 8);

                    // need to enqueue this and handle it in the netconnection heartbeat; so be able to send resends together with normal sends
                    m_queuedIncomingAcks.Enqueue(new NetTuple <NetMessageType, int>(acktp, seqNr));
                }
                break;

            case NetMessageType.Ping:
                int pingNr = m_peer.m_receiveBuffer[ptr++];
                SendPong(pingNr);
                break;

            case NetMessageType.Pong:
                NetIncomingMessage pmsg = m_peer.SetupReadHelperMessage(ptr, payloadLength);
                int   pongNr            = pmsg.ReadByte();
                float remoteSendTime    = pmsg.ReadSingle();
                ReceivedPong(now, pongNr, remoteSendTime);
                break;

            case NetMessageType.ExpandMTURequest:
                SendMTUSuccess(payloadLength);
                break;

            case NetMessageType.ExpandMTUSuccess:
                if (m_peer.Configuration.AutoExpandMTU == false)
                {
                    m_peer.LogDebug("Received ExpandMTURequest altho AutoExpandMTU is turned off!");
                    break;
                }
                NetIncomingMessage emsg = m_peer.SetupReadHelperMessage(ptr, payloadLength);
                int size = emsg.ReadInt32();
                HandleExpandMTUSuccess(now, size);
                break;

            case NetMessageType.NatIntroduction:
                // Unusual situation where server is actually already known, but got a nat introduction - oh well, lets handle it as usual
                m_peer.HandleNatIntroduction(ptr);
                break;

            case NetMessageType.Unconnected:
            case NetMessageType.UserUnreliable:
            case NetMessageType.UserSequenced1:
            case NetMessageType.UserSequenced2:
            case NetMessageType.UserSequenced3:
            case NetMessageType.UserSequenced4:
            case NetMessageType.UserSequenced5:
            case NetMessageType.UserSequenced6:
            case NetMessageType.UserSequenced7:
            case NetMessageType.UserSequenced8:
            case NetMessageType.UserSequenced9:
            case NetMessageType.UserSequenced10:
            case NetMessageType.UserSequenced11:
            case NetMessageType.UserSequenced12:
            case NetMessageType.UserSequenced13:
            case NetMessageType.UserSequenced14:
            case NetMessageType.UserSequenced15:
            case NetMessageType.UserSequenced16:
            case NetMessageType.UserSequenced17:
            case NetMessageType.UserSequenced18:
            case NetMessageType.UserSequenced19:
            case NetMessageType.UserSequenced20:
            case NetMessageType.UserSequenced21:
            case NetMessageType.UserSequenced22:
            case NetMessageType.UserSequenced23:
            case NetMessageType.UserSequenced24:
            case NetMessageType.UserSequenced25:
            case NetMessageType.UserSequenced26:
            case NetMessageType.UserSequenced27:
            case NetMessageType.UserSequenced28:
            case NetMessageType.UserSequenced29:
            case NetMessageType.UserSequenced30:
            case NetMessageType.UserSequenced31:
            case NetMessageType.UserSequenced32:
            case NetMessageType.UserReliableUnordered:
            case NetMessageType.UserReliableSequenced1:
            case NetMessageType.UserReliableSequenced2:
            case NetMessageType.UserReliableSequenced3:
            case NetMessageType.UserReliableSequenced4:
            case NetMessageType.UserReliableSequenced5:
            case NetMessageType.UserReliableSequenced6:
            case NetMessageType.UserReliableSequenced7:
            case NetMessageType.UserReliableSequenced8:
            case NetMessageType.UserReliableSequenced9:
            case NetMessageType.UserReliableSequenced10:
            case NetMessageType.UserReliableSequenced11:
            case NetMessageType.UserReliableSequenced12:
            case NetMessageType.UserReliableSequenced13:
            case NetMessageType.UserReliableSequenced14:
            case NetMessageType.UserReliableSequenced15:
            case NetMessageType.UserReliableSequenced16:
            case NetMessageType.UserReliableSequenced17:
            case NetMessageType.UserReliableSequenced18:
            case NetMessageType.UserReliableSequenced19:
            case NetMessageType.UserReliableSequenced20:
            case NetMessageType.UserReliableSequenced21:
            case NetMessageType.UserReliableSequenced22:
            case NetMessageType.UserReliableSequenced23:
            case NetMessageType.UserReliableSequenced24:
            case NetMessageType.UserReliableSequenced25:
            case NetMessageType.UserReliableSequenced26:
            case NetMessageType.UserReliableSequenced27:
            case NetMessageType.UserReliableSequenced28:
            case NetMessageType.UserReliableSequenced29:
            case NetMessageType.UserReliableSequenced30:
            case NetMessageType.UserReliableSequenced31:
            case NetMessageType.UserReliableSequenced32:
            case NetMessageType.UserReliableOrdered1:
            case NetMessageType.UserReliableOrdered2:
            case NetMessageType.UserReliableOrdered3:
            case NetMessageType.UserReliableOrdered4:
            case NetMessageType.UserReliableOrdered5:
            case NetMessageType.UserReliableOrdered6:
            case NetMessageType.UserReliableOrdered7:
            case NetMessageType.UserReliableOrdered8:
            case NetMessageType.UserReliableOrdered9:
            case NetMessageType.UserReliableOrdered10:
            case NetMessageType.UserReliableOrdered11:
            case NetMessageType.UserReliableOrdered12:
            case NetMessageType.UserReliableOrdered13:
            case NetMessageType.UserReliableOrdered14:
            case NetMessageType.UserReliableOrdered15:
            case NetMessageType.UserReliableOrdered16:
            case NetMessageType.UserReliableOrdered17:
            case NetMessageType.UserReliableOrdered18:
            case NetMessageType.UserReliableOrdered19:
            case NetMessageType.UserReliableOrdered20:
            case NetMessageType.UserReliableOrdered21:
            case NetMessageType.UserReliableOrdered22:
            case NetMessageType.UserReliableOrdered23:
            case NetMessageType.UserReliableOrdered24:
            case NetMessageType.UserReliableOrdered25:
            case NetMessageType.UserReliableOrdered26:
            case NetMessageType.UserReliableOrdered27:
            case NetMessageType.UserReliableOrdered28:
            case NetMessageType.UserReliableOrdered29:
            case NetMessageType.UserReliableOrdered30:
            case NetMessageType.UserReliableOrdered31:
            case NetMessageType.UserReliableOrdered32:
            case NetMessageType.Unused1:
            case NetMessageType.Unused2:
            case NetMessageType.Unused3:
            case NetMessageType.Unused4:
            case NetMessageType.Unused5:
            case NetMessageType.Unused6:
            case NetMessageType.Unused7:
            case NetMessageType.Unused8:
            case NetMessageType.Unused9:
            case NetMessageType.Unused10:
            case NetMessageType.Unused11:
            case NetMessageType.Unused12:
            case NetMessageType.Unused13:
            case NetMessageType.Unused14:
            case NetMessageType.Unused15:
            case NetMessageType.Unused16:
            case NetMessageType.Unused17:
            case NetMessageType.Unused18:
            case NetMessageType.Unused19:
            case NetMessageType.Unused20:
            case NetMessageType.Unused21:
            case NetMessageType.Unused22:
            case NetMessageType.Unused23:
            case NetMessageType.Unused24:
            case NetMessageType.Unused25:
            case NetMessageType.Unused26:
            case NetMessageType.Unused27:
            case NetMessageType.Unused28:
            case NetMessageType.Unused29:
            case NetMessageType.Discovery:
            case NetMessageType.DiscoveryResponse:
            case NetMessageType.NatPunchMessage:
            case NetMessageType.NatIntroductionConfirmRequest:
            case NetMessageType.NatIntroductionConfirmed:
            default:
                m_peer.LogWarning("Connection received unhandled library message: " + tp);
                break;
            }
        }
コード例 #34
0
        // received a library message while Connected
        internal void ReceivedLibraryMessage(NetMessageType tp, int ptr, int payloadLength)
        {
            m_peer.VerifyNetworkThread();

            float now = (float)NetTime.Now;

            switch (tp)
            {
            case NetMessageType.Connect:
                m_peer.LogDebug("Received handshake message (" + tp + ") despite connection being in place");
                break;

            case NetMessageType.ConnectResponse:
                // handshake message must have been lost
                HandleConnectResponse(now, tp, ptr, payloadLength);
                break;

            case NetMessageType.ConnectionEstablished:
                // do nothing, all's well
                break;

            case NetMessageType.LibraryError:
#if DEBUG
                throw new NetException("LibraryError received by ReceivedLibraryMessage; this usually indicates a malformed message");
#else
                break;
#endif

            case NetMessageType.Disconnect:
                NetIncomingMessage msg = m_peer.SetupReadHelperMessage(ptr, payloadLength);
                ExecuteDisconnect(msg.ReadString(), false);
                break;

            case NetMessageType.Acknowledge:
                for (int i = 0; i < payloadLength; i += 3)
                {
                    NetMessageType acktp = (NetMessageType)m_peer.m_receiveBuffer[ptr++];                             // netmessagetype
                    int            seqNr = m_peer.m_receiveBuffer[ptr++];
                    seqNr |= (m_peer.m_receiveBuffer[ptr++] << 8);

                    // need to enqueue this and handle it in the netconnection heartbeat; so be able to send resends together with normal sends
                    m_queuedIncomingAcks.Enqueue(new NetTuple <NetMessageType, int>(acktp, seqNr));
                }
                break;

            case NetMessageType.Ping:
                int pingNr = m_peer.m_receiveBuffer[ptr++];
                SendPong(pingNr);
                break;

            case NetMessageType.Pong:
                NetIncomingMessage pmsg = m_peer.SetupReadHelperMessage(ptr, payloadLength);
                int   pongNr            = pmsg.ReadByte();
                float remoteSendTime    = pmsg.ReadSingle();
                ReceivedPong(now, pongNr, remoteSendTime);
                break;

            case NetMessageType.ExpandMTURequest:
                SendMTUSuccess(payloadLength);
                break;

            case NetMessageType.ExpandMTUSuccess:
                NetIncomingMessage emsg = m_peer.SetupReadHelperMessage(ptr, payloadLength);
                int size = emsg.ReadInt32();
                HandleExpandMTUSuccess(now, size);
                break;

            case NetMessageType.NatIntroduction:
                // Unusual situation where server is actually already known, but got a nat introduction - oh well, lets handle it as usual
                m_peer.HandleNatIntroduction(ptr);
                break;

            default:
                m_peer.LogWarning("Connection received unhandled library message: " + tp);
                break;
            }
        }