Esempio n. 1
0
 /// <summary> Registers an instance of a MonoBehaviour to receive RPCs not associated with a NetView. </summary>
 public void RegisterRpcListener(MonoBehaviour listener)
 {
     foreach (KeyValuePair <string, RpcMethodInfo> cachedRpc in RpcInfoCache.RpcMethods())
     {
         if (!cachedRpc.Value.MethodInfoLookup.ContainsKey(listener.GetType()))
         {
             continue;
         }
         rpcObjectInstances.Add(cachedRpc.Value.Name, listener);
     }
 }
Esempio n. 2
0
        /// <summary> Awake is a Unity convention. Unity invokes this method first when instantiated. </summary>
        private void Awake()
        {
            Application.runInBackground = true;
            Application.targetFrameRate = TargetFrameRate;

            Request = new RequestDispatcher(this);
            Rpc     = new RpcDispatcher(this);

            RpcInfoCache.RpcMethods();

            RegisterCommandParams();
        }
Esempio n. 3
0
        /// <summary> Called by the server to generate IDs for local RPCs. </summary>
        internal void AssignLocalRpcs()
        {
            int i = 0;

            foreach (KeyValuePair <string, RpcMethodInfo> kvp in RpcInfoCache.RpcMethods())
            {
                for (i++; i < 1800; i++)
                {
                    if (HasName((ushort)i))
                    {
                        continue;
                    }
                    idToName.Add((ushort)i, kvp.Value.Name);
                    nameToId.Add(kvp.Value.Name, (ushort)i);
                    break;
                }
            }
        }
Esempio n. 4
0
        /// <summary> Sends a request to the server for each local RPC method name that needs an ID assignment. </summary>
        internal void RequestAssignments(NetConnection connection)
        {
            foreach (string methodName in RpcInfoCache.RpcMethods().Keys)
            {
                if (HasId(methodName))
                {
                    if (!HasName(NameToId(methodName)))
                    {
                        idToName.Add(NameToId(methodName), methodName);
                    }
                    continue;
                }
                Socket.Command.Send((int)Cmd.AssignmentRequest, connection, methodName);
            }

            if (IdCount >= RpcInfoCache.Count)
            {
                Socket.SendRequirementsMet(connection);
            }
        }