Esempio n. 1
0
        /// <summary>Gets a <see cref="ITinyNetComponent"/> by it's network identifier.</summary>
        /// <param name="networkId">The network identifier.</param>
        /// <param name="localId">The local identifier on the TinyNetIdentity.</param>
        /// <returns></returns>
        public static ITinyNetComponent GetTinyNetComponentByNetworkID(int networkId, byte localId)
        {
            ITinyNetComponent reference = null;

            //return _localNetObjects.ContainsKey(nId) ? _localNetObjects[nId] : null;
            if (networkId >= 0)
            {
                TinyNetIdentity tinyNetRef = GetTinyNetIdentityByNetworkID(networkId);
                reference = tinyNetRef.GetComponentById(localId);
            }
            return(reference);
        }
Esempio n. 2
0
        //============ Static Methods =======================//



        //============ Object Networking ====================//

        /// <summary>
        /// Sends the RPC to server.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="rpcMethodIndex">Index of the RPC method.</param>
        /// <param name="iObj">The <see cref="ITinyNetComponent"/> instance.</param>
        public void SendRPCToServer(NetDataWriter stream, int rpcMethodIndex, ITinyNetComponent iObj)
        {
            //TODO: Pack rpc messages
            var msg = new TinyNetRPCMessage();

            msg.networkID      = iObj.TinyInstanceID.NetworkID;
            msg.componentID    = iObj.TinyInstanceID.ComponentID;
            msg.rpcMethodIndex = rpcMethodIndex;
            msg.frameTick      = LastServerTick;
            msg.parameters     = stream.Data;

            SendMessageByChannelToTargetConnection(msg, DeliveryMethod.ReliableOrdered, connToHost);
        }
Esempio n. 3
0
        /// <summary>
        /// Sends the RPC to all clients.
        /// </summary>
        /// <param name="stream">The stream.</param>
        /// <param name="rpcMethodIndex">Index of the RPC method.</param>
        /// <param name="iObj">The object.</param>
        public void SendRPCToAllClients(NetDataWriter stream, int rpcMethodIndex, ITinyNetComponent iObj)
        {
            //TODO: Pack rpc messages
            var msg = new TinyNetRPCMessage();

            msg.networkID      = iObj.TinyInstanceID.NetworkID;
            msg.componentID    = iObj.TinyInstanceID.ComponentID;
            msg.rpcMethodIndex = rpcMethodIndex;
            msg.frameTick      = ServerTick;
            msg.parameters     = stream.Data;

            TinyNetIdentity tni = GetTinyNetIdentityByNetworkID(iObj.TinyInstanceID.NetworkID);

            SendMessageByChannelToAllObserversOf(tni, msg, DeliveryMethod.ReliableOrdered);
        }