SetupInstantiateId() public method

Check the argument update with the stream and start index
public SetupInstantiateId ( NetworkingStream stream, int start ) : ulong
stream NetworkingStream Stream to be updated
start int Start index
return ulong
コード例 #1
0
        /// <summary>
        /// To Invoke an RPC on a given Networking Stream RPC
        /// </summary>
        /// <param name="stream">Networking Stream RPC to read from</param>
        public bool InvokeRPC(NetworkingStreamRPC stream)
        {
            lock (rpcStackMutex)
            {
                tmpRPCMapId = ObjectMapper.Map <int>(stream);

                if (!RPCs.ContainsKey(tmpRPCMapId))
                {
                    return(true);
                }

                stream.SetName(RPCs[tmpRPCMapId].Key.Name);

                List <object> args = new List <object>();

                MethodInfo            invoke     = null;
                List <IBRPCIntercept> attributes = null;
                foreach (KeyValuePair <int, KeyValuePair <MethodInfo, List <IBRPCIntercept> > > m in RPCs)
                {
                    if (m.Value.Key.Name == stream.MethodName)
                    {
                        invoke     = m.Value.Key;
                        attributes = m.Value.Value;
                        break;
                    }
                }

                int             start = stream.Bytes.StartIndex(stream.ByteReadIndex);
                ParameterInfo[] pars  = invoke.GetParameters();
                foreach (ParameterInfo p in pars)
                {
                    if (p.ParameterType == typeof(MessageInfo))
                    {
                        args.Add(new MessageInfo(stream.RealSenderId, stream.FrameIndex));
                    }
                    else
                    {
                        args.Add(ObjectMapper.Map(p.ParameterType, stream));
                    }
                }

                stream.SetArguments(args.ToArray());

                if (ReferenceEquals(this, NetworkingManager.Instance))
                {
                    if (OwningNetWorker.IsServer)
                    {
                        if (stream.MethodName == NetworkingStreamRPC.INSTANTIATE_METHOD_NAME)
                        {
                            stream.Arguments[1] = stream.SetupInstantiateId(stream, start);
                        }
                        else if (stream.MethodName == NetworkingStreamRPC.DESTROY_METHOD_NAME)
                        {
                            if (OwningNetWorker.ClearBufferedInstantiateFromID((ulong)args[0]))
                            {
                                // Set flag if method removed instantiate
                                IsClearedForBuffer = !stream.BufferedRPC;
                            }
                        }
                    }
                }

                foreach (IBRPCIntercept interceptor in attributes)
                {
                    if (!interceptor.ValidateRPC(stream))
                    {
                        return(false);
                    }
                }

                rpcStack.Add(stream);

                return(true);
            }
        }
コード例 #2
0
		/// <summary>
		/// To Invoke an RPC on a given Networking Stream RPC
		/// </summary>
		/// <param name="stream">Networking Stream RPC to read from</param>
		public void InvokeRPC(NetworkingStreamRPC stream)
		{
			tmpRPCMapId = ObjectMapper.Map<int>(stream);
			if (!RPCs.ContainsKey(tmpRPCMapId))
				return;

			stream.SetName(RPCs[tmpRPCMapId].Name);

			List<object> args = new List<object>();

			MethodInfo invoke = null;
			foreach (KeyValuePair<int, MethodInfo> m in RPCs)
			{
				if (m.Value.Name == stream.MethodName)
				{
					invoke = m.Value;
					break;
				}
			}

			int start = stream.Bytes.StartIndex(stream.ByteReadIndex);
			ParameterInfo[] pars = invoke.GetParameters();
			foreach (ParameterInfo p in pars)
				args.Add(ObjectMapper.Map(p.ParameterType, (NetworkingStream)stream));

			stream.SetArguments(args.ToArray());

			if (ReferenceEquals(this, NetworkingManager.Instance))
			{
				if (OwningNetWorker.IsServer && stream.MethodName == NetworkingStreamRPC.INSTANTIATE_METHOD_NAME)
					stream.Arguments[1] = stream.SetupInstantiateId(stream, start);

				if (stream.MethodName == NetworkingStreamRPC.DESTROY_METHOD_NAME)
				{
					if (Networking.PrimarySocket.ClearBufferedInstantiateFromID((ulong)args[0]))
					{
						// Set flag if method removed instantiate
						IsClearedForBuffer = !stream.BufferedRPC;
					}
				}
			}

			rpcStack.Add(stream);
		}
コード例 #3
0
		/// <summary>
		/// To Invoke an RPC on a given Networking Stream RPC
		/// </summary>
		/// <param name="stream">Networking Stream RPC to read from</param>
		public void InvokeRPC(NetworkingStreamRPC stream)
		{
			tmpRPCMapId = ObjectMapper.Map<int>(stream);
			if (!RPCs.ContainsKey(tmpRPCMapId))
				return;

			stream.SetName(RPCs[tmpRPCMapId].Name);

			List<object> args = new List<object>();

			MethodInfo invoke = null;
			foreach (KeyValuePair<int, MethodInfo> m in RPCs)
			{
				if (m.Value.Name == stream.MethodName)
				{
					invoke = m.Value;
					break;
				}
			}

			int start = stream.Bytes.StartIndex(stream.ByteReadIndex);
			ParameterInfo[] pars = invoke.GetParameters();
			foreach (ParameterInfo p in pars)
				args.Add(ObjectMapper.Map(p.ParameterType, (NetworkingStream)stream));

			stream.SetArguments(args.ToArray());

			if (OwningNetWorker.IsServer && stream.MethodName == NetworkingStreamRPC.INSTANTIATE_METHOD_NAME)
				stream.Arguments[1] = stream.SetupInstantiateId(stream, start);

			rpcStack.Add(stream);
		}
コード例 #4
0
		/// <summary>
		/// To Invoke an RPC on a given Networking Stream RPC
		/// </summary>
		/// <param name="stream">Networking Stream RPC to read from</param>
		public bool InvokeRPC(NetworkingStreamRPC stream)
		{
			lock (rpcStackMutex)
			{
				tmpRPCMapId = ObjectMapper.Map<int>(stream);

				if (!RPCs.ContainsKey(tmpRPCMapId))
					return true;

				stream.SetName(RPCs[tmpRPCMapId].Key.Name);
				
				List<object> args = new List<object>();

				MethodInfo invoke = null;
				List<IBRPCIntercept> attributes = null;
				foreach (KeyValuePair<int, KeyValuePair<MethodInfo, List<IBRPCIntercept>>> m in RPCs)
				{
					if (m.Value.Key.Name == stream.MethodName)
					{
						invoke = m.Value.Key;
						attributes = m.Value.Value;
						break;
					}
				}

				int start = stream.Bytes.StartIndex(stream.ByteReadIndex);
				ParameterInfo[] pars = invoke.GetParameters();
				foreach (ParameterInfo p in pars)
				{
					if (p.ParameterType == typeof(MessageInfo))
						args.Add(new MessageInfo(stream.RealSenderId, stream.FrameIndex));
					else
						args.Add(ObjectMapper.Map(p.ParameterType, stream));
				}

				stream.SetArguments(args.ToArray());

				if (ReferenceEquals(this, NetworkingManager.Instance))
				{
					if (OwningNetWorker.IsServer)
					{
						if (stream.MethodName == NetworkingStreamRPC.INSTANTIATE_METHOD_NAME)
							stream.Arguments[1] = stream.SetupInstantiateId(stream, start);
						else if (stream.MethodName == NetworkingStreamRPC.DESTROY_METHOD_NAME)
						{
							if (OwningNetWorker.ClearBufferedInstantiateFromID((ulong)args[0]))
							{
								// Set flag if method removed instantiate
								IsClearedForBuffer = !stream.BufferedRPC;
							}
						}
					}
				}

				foreach (IBRPCIntercept interceptor in attributes)
				{
					if (!interceptor.ValidateRPC(stream))
						return false;
				}

				rpcStack.Add(stream);

				return true;
			}
		}