当前位置: 首页>>代码示例>>C#>>正文


C# Network.NetIncomingMessage类代码示例

本文整理汇总了C#中Lidgren.Network.NetIncomingMessage的典型用法代码示例。如果您正苦于以下问题:C# NetIncomingMessage类的具体用法?C# NetIncomingMessage怎么用?C# NetIncomingMessage使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


NetIncomingMessage类属于Lidgren.Network命名空间,在下文中一共展示了NetIncomingMessage类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: OnDeserialize

 /// <summary>
 /// read the message
 /// </summary>
 /// <param name="message">message to read from</param>
 public void OnDeserialize(NetIncomingMessage message)
 {
     X = message.ReadFloat();
     Y = message.ReadFloat();
     Z = message.ReadFloat();
     W = message.ReadFloat();
 }
开发者ID:traleven,项目名称:PNet,代码行数:11,代码来源:SerializedStructs.cs

示例2: ToOtherPlayers

        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);
        }
开发者ID:andva,项目名称:Eulerian-ShootEmUp,代码行数:25,代码来源:Package.cs

示例3: ClientDisconnectedTransferableData

 public ClientDisconnectedTransferableData(NetIncomingMessage message)
 {
     SessionID = message.ReadInt64();
     ID = message.ReadInt32();
     IsValid = message.ReadBoolean();
     PlayerIndex = message.ReadInt16();
 }
开发者ID:elefantstudio-se,项目名称:xna-lidgren-multiplayer-game,代码行数:7,代码来源:ClientDisconnectedTransferableData.cs

示例4: ConnectionRequestEventArgs

 // Constructor
 public ConnectionRequestEventArgs(NetIncomingMessage msg, string note, string username, string password)
 {
     this.msg = msg;
     this.username = username;
     this.password = password;
     this.note = note;
 }
开发者ID:rockhowse,项目名称:Gurkenplayer,代码行数:8,代码来源:MPEventArgs.cs

示例5: ReadPayload

 public override void ReadPayload(NetIncomingMessage message)
 {
     base.ReadPayload(message);
     Image = message.ReadBytes(message.ReadInt32());
     Number = message.ReadUInt32();
     SendIndex = message.ReadInt32();
 }
开发者ID:theslyone,项目名称:RemoteDesktop,代码行数:7,代码来源:ResponseScreenshotMessage.cs

示例6: InitializeNetwork

		private void InitializeNetwork()
		{
			lock (m_initializeLock)
			{
				m_configuration.Lock();

				if (m_status == NetPeerStatus.Running)
					return;

				InitializePools();

				m_releasedIncomingMessages.Clear();
				m_unsentUnconnectedMessages.Clear();
				m_handshakes.Clear();

				// bind to socket
				IPEndPoint iep = null;

				iep = new IPEndPoint(m_configuration.LocalAddress, m_configuration.Port);
				EndPoint ep = (EndPoint)iep;

				m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
				m_socket.ReceiveBufferSize = m_configuration.ReceiveBufferSize;
				m_socket.SendBufferSize = m_configuration.SendBufferSize;
				m_socket.Blocking = false;
				m_socket.Bind(ep);

				IPEndPoint boundEp = m_socket.LocalEndPoint as IPEndPoint;
				LogDebug("Socket bound to " + boundEp + ": " + m_socket.IsBound);
				m_listenPort = boundEp.Port;

				m_receiveBuffer = new byte[m_configuration.ReceiveBufferSize];
				m_sendBuffer = new byte[m_configuration.SendBufferSize];
				m_readHelperMessage = new NetIncomingMessage(NetIncomingMessageType.Error);
				m_readHelperMessage.m_data = m_receiveBuffer;

				byte[] macBytes = new byte[8];
				NetRandom.Instance.NextBytes(macBytes);

#if IS_MAC_AVAILABLE
			System.Net.NetworkInformation.PhysicalAddress pa = NetUtility.GetMacAddress();
			if (pa != null)
			{
				macBytes = pa.GetAddressBytes();
				LogVerbose("Mac address is " + NetUtility.ToHexString(macBytes));
			}
			else
			{
				LogWarning("Failed to get Mac address");
			}
#endif
				byte[] epBytes = BitConverter.GetBytes(boundEp.GetHashCode());
				byte[] combined = new byte[epBytes.Length + macBytes.Length];
				Array.Copy(epBytes, 0, combined, 0, epBytes.Length);
				Array.Copy(macBytes, 0, combined, epBytes.Length, macBytes.Length);
				m_uniqueIdentifier = BitConverter.ToInt64(SHA1.Create().ComputeHash(combined), 0);

				m_status = NetPeerStatus.Running;
			}
		}
开发者ID:andva,项目名称:Eulerian-ShootEmUp,代码行数:60,代码来源:NetPeer.Internal.cs

示例7: ReleaseMessage

		internal void ReleaseMessage(NetIncomingMessage msg)
		{
			NetException.Assert(msg.m_incomingMessageType != NetIncomingMessageType.Error);

			if (msg.m_isFragment)
			{
				HandleReleasedFragment(msg);
				return;
			}

			m_releasedIncomingMessages.Enqueue(msg);

			if (m_messageReceivedEvent != null)
				m_messageReceivedEvent.Set();

			if (m_receiveCallbacks != null)
			{
				foreach (var tuple in m_receiveCallbacks)
				{
					try
					{
						tuple.Item1.Post(tuple.Item2, this);
					}
					catch (Exception ex)
					{
						LogWarning("Receive callback exception:" + ex);
					}
				}
			}
		}
开发者ID:g1111111g,项目名称:lidgren-network-gen3,代码行数:30,代码来源:NetPeer.Internal.cs

示例8: ReceiveMessage

		internal override void ReceiveMessage(NetIncomingMessage message)
		{
			int relate = NetUtility.RelativeSequenceNumber(message.m_sequenceNumber, m_windowStart);

			// ack no matter what
			m_connection.QueueAck(message.m_receivedMessageType, message.m_sequenceNumber);

			if (relate == 0)
			{
				// Log("Received message #" + message.SequenceNumber + " right on time");

				//
				// excellent, right on time
				//
				//m_peer.LogVerbose("Received RIGHT-ON-TIME " + message);

				AdvanceWindow();
				m_peer.ReleaseMessage(message);

				// release withheld messages
				int nextSeqNr = (message.m_sequenceNumber + 1) % NetConstants.NumSequenceNumbers;

				while (m_earlyReceived[nextSeqNr % m_windowSize])
				{
					message = m_withheldMessages[nextSeqNr % m_windowSize];
					NetException.Assert(message != null);

					// remove it from withheld messages
					m_withheldMessages[nextSeqNr % m_windowSize] = null;

					m_peer.LogVerbose("Releasing withheld message #" + message);

					m_peer.ReleaseMessage(message);

					AdvanceWindow();
					nextSeqNr++;
				}

				return;
			}

			if (relate < 0)
			{
				m_peer.LogVerbose("Received message #" + message.m_sequenceNumber + " DROPPING DUPLICATE");
				// duplicate
				return;
			}

			// relate > 0 = early message
			if (relate > m_windowSize)
			{
				// too early message!
				m_peer.LogDebug("Received " + message + " TOO EARLY! Expected " + m_windowStart);
				return;
			}

			m_earlyReceived.Set(message.m_sequenceNumber % m_windowSize, true);
			m_peer.LogVerbose("Received " + message + " WITHHOLDING, waiting for " + m_windowStart);
			m_withheldMessages[message.m_sequenceNumber % m_windowSize] = message;
		}
开发者ID:Cardanis,项目名称:MonoGame,代码行数:60,代码来源:NetReliableOrderedReceiver.cs

示例9: Init

 public override void Init(NetIncomingMessage msg, params float[] p_afInitFloats)
 {
     this.rcShadow = new StaticRenderComponent(CAS.RegionContent.Load<Texture2D>("Sprites/Monster/Winterland/Frostling Scoundrel/Shadow"), this.xTransform);
     Program.game.xRenderMaster.RegisterShadowLayer(this.rcShadow, 60);
     this.fVelocity = p_afInitFloats[0];
     this.v2Direction = new Vector2(p_afInitFloats[1], p_afInitFloats[2]);
 }
开发者ID:ancientgods,项目名称:SoG,代码行数:7,代码来源:_EnemySpells_SmallSnowBall.cs

示例10: ApproveConnection

        //This is called very first when a client connects to the server, but before OnPlayerConnected
        private static void ApproveConnection(NetIncomingMessage netIncomingMessage)
        {
            netIncomingMessage.SenderConnection.Approve();

            //Other things you can do: spawn a separate thread that eventually decides if a connection should be approved or not,
            //then approve the connection in the gameupdate loop
        }
开发者ID:Antaresgames,项目名称:PNet,代码行数:8,代码来源:Program.cs

示例11: Read

 public override void Read(NetIncomingMessage msg)
 {
     Id = msg.ReadUInt16();
     int count = msg.ReadInt32();
     for(int i = 0; i < count; ++i)
         Cards.Add(msg.ReadString());
 }
开发者ID:DatZach,项目名称:HumanityAgainstCards,代码行数:7,代码来源:WinnerPicked.cs

示例12: Decode

 public void Decode(NetIncomingMessage im)
 {
     this.Username = im.ReadString();
     this.ID = im.ReadByte();
     this.Me = im.ReadBoolean();
     this.Color = new Color(im.ReadByte(), im.ReadByte(), im.ReadByte());
 }
开发者ID:Express50,项目名称:Bricklayer,代码行数:7,代码来源:PlayerJoinMessage.cs

示例13: ReadData

 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;
     }
 }
开发者ID:fusspawn,项目名称:sobriety,代码行数:32,代码来源:Attribute.cs

示例14: ProcessPacket

        /// <summary>
        /// Alerts the packet service about possible packets that need processing
        /// </summary>
        /// <param name="packetID">The type of packet that is expected</param>
        /// <param name="incomingMessage">The data contained within the packet</param>
        public void ProcessPacket(int packetID, NetIncomingMessage incomingMessage)
        {
            //TODO: Type.InvokeMember(...) is an expensive call. Do monitor this if at all possible.
            //It'll likely be fine, and it adds great design addition. No nasty switches. Send and forget.

            if (!_cache.ContainsKey(packetID))
                throw new Exception("The given packet type is missing! Was it marked properly and given an attribute?");

            //Take our incoming message and type
            var type = _cache[packetID];

            var val = new object[1];
            val[0] = incomingMessage;

            //Take the given type in the context and create our packet from it

            // Try and fetch the packet, otherwise abort it

            var returnValue =
                (Packet)type.InvokeMember("FromNetBuffer", BindingFlags.InvokeMethod, null, type, val);
            returnValue.Sender = incomingMessage.SenderConnection;

            //Automated packet service
            _packetService.ProcessReceivedPacket(returnValue);

            //Logger.Instance.Log(Level.Warn, "A packet that had a malformed payload was attempt to be sent. Ignoring for now.");
        }
开发者ID:hilts-vaughan,项目名称:inspire,代码行数:32,代码来源:PacketProcessor.cs

示例15: Decode

 public void Decode(NetIncomingMessage im)
 {
     this.MessageTime = im.ReadDouble();
     this.Id = im.ReadInt32();
     this.OldPosition = im.ReadInt32();
     this.NewPosition = im.ReadInt32();
 }
开发者ID:Gothen111,项目名称:2DWorld,代码行数:7,代码来源:CreatureInventoryItemPositionChangeMessage.cs


注:本文中的Lidgren.Network.NetIncomingMessage类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。