Exemplo n.º 1
0
        protected virtual void OnRegisterScene_Server(RpcArgs pArgs)
        {
            bool requireConfirmation = pArgs.GetNext <bool>();

            byte[]                   data               = pArgs.GetNext <byte[]>();
            RPCServiceCallback       callbackRPC        = data.ByteArrayToObject <RPCServiceCallback>();
            RPCNetworkSceneTemplate  templateRPC        = callbackRPC.data.ByteArrayToObject <RPCNetworkSceneTemplate>();
            NodeNetworkSceneTemplate registeredTemplate = GetRegisteredScene(templateRPC.sceneName);
            bool addSuccess = (registeredTemplate != null && registeredTemplate.NodeId == callbackRPC.sourceNodeId) || AddRegisteredScene(callbackRPC.sourceNodeId, new NodeNetworkSceneTemplate(callbackRPC.sourceNodeId, templateRPC));

            if (requireConfirmation)
            {
                //Only the callbackRPC.state is important for RPC_CONFIRM
                callbackRPC.state = (addSuccess) ? ServiceCallbackStateEnum.RESPONSE_SUCCESS : ServiceCallbackStateEnum.RESPONSE_FAILED;
                callbackRPC.data  = null;
                networkObject.SendRpc(pArgs.Info.SendingPlayer, RPC_CONFIRM_SCENE, callbackRPC.ObjectToByteArray());
            }
        }
Exemplo n.º 2
0
        protected virtual void OnReceiveLookupScene_ServerClient(RpcArgs pArgs)
        {
            uint nodeId = pArgs.GetNext <uint>();

            byte[]                   data         = pArgs.GetNext <byte[]>();
            RPCServiceCallback       callbackRPC  = data.ByteArrayToObject <RPCServiceCallback>();
            RPCNetworkSceneTemplate  templateRPC  = callbackRPC.data.ByteArrayToObject <RPCNetworkSceneTemplate>();
            NodeNetworkSceneTemplate nodeTemplate = new NodeNetworkSceneTemplate(nodeId, templateRPC);
            ServiceCallback          callback;

            if (!_pendingServiceCallbacks.TryGetValue(callbackRPC.callbackId, out callback))
            {
                return;
            }

            if (_enableLookupCaching && nodeTemplate.BuildIndex >= 0)
            {
                AddCacheLookup(nodeTemplate);
            }

            RemovePendingServiceCallback(callback.CallbackId);
            callback.RaiseResponse(GameTime.fixedTime, nodeTemplate.ObjectToByteArray());
        }
Exemplo n.º 3
0
 public NodeNetworkSceneTemplate(uint pNodeId, RPCNetworkSceneTemplate pNetworkSceneTemplateRPC) : base(pNetworkSceneTemplateRPC)
 {
     _nodeId = pNodeId;
 }