Example #1
0
 /* Callbacks from Dispatcher */
 public void OnBEventInvoked <H>(BEvent <H> bEvent, H bEHandle, BEventReplicationType bEInvocationType, ENetworkID targetNetworkID) where H : AbstractBEHandle
 {
     if (BEventDispatcher)
     {
         bEHandle.InvokingNetworkID = LocalNetworkID;
         BEventDispatcher.OnBEventInvoked(bEvent, bEHandle, bEInvocationType, targetNetworkID);
     }
 }
Example #2
0
        public void Server_RequestBroadcastEvent(AbstractBEHandle bEHandle, BEventReplicationType eventInvocationType, ENetworkID callingNetworkID, ENetworkID targetNetworkID)
        {
            //Debug.Log("Server_RequestBroadcastEvent : " + callingNetworkID + " - " + eventInvocationType);

            string serializedBEHandle = BUtils.SerializeObject(bEHandle);


            Server_OnBroadcastEvent(serializedBEHandle, eventInvocationType, callingNetworkID, targetNetworkID);
        }
Example #3
0
        public override void OnBEventInvoked <H>(BEvent <H> bEvent, H bEHandle, BEventReplicationType eventInvocationType, ENetworkID targetNetworkID)
        {
            // Broadcast locally if still not connected
            if (LocalNetworkID == ENetworkID.LOCAL)
            {
                bEvent.OnProceedInvokation(bEHandle);
                return;
            }

            switch (eventInvocationType)
            {
            case BEventReplicationType.TO_ALL:
                //Broadcast locally
                bEvent.OnProceedInvokation(bEHandle);

                // Publish to all other clients on the network
                foreach (ENetworkID networkID in connectedNetworkIDs.Keys)
                {
                    if (networkID != LocalNetworkID)
                    {
                        Publish_TOPIC_BROADCAST_BEVENT(bEHandle, networkID);
                    }
                }
                break;

            case BEventReplicationType.TO_ALL_OTHERS:
                // Publish to all other clients on the network
                foreach (ENetworkID networkID in connectedNetworkIDs.Keys)
                {
                    if (networkID != LocalNetworkID)
                    {
                        Publish_TOPIC_BROADCAST_BEVENT(bEHandle, networkID);
                    }
                }
                break;

            case BEventReplicationType.LOCAL:
                // Broadcast locally
                bEvent.OnProceedInvokation(bEHandle);
                break;

            case BEventReplicationType.TO_TARGET:
                if (LocalNetworkID == targetNetworkID)
                {
                    // Broadcast locally
                    bEvent.OnProceedInvokation(bEHandle);
                }
                else if (IS_NOT_NONE(targetNetworkID))
                {
                    Publish_TOPIC_BROADCAST_BEVENT(bEHandle, targetNetworkID);
                }
                break;
            }
        }
Example #4
0
        private void Server_OnBroadcastEvent(string serializedBEHandle, BEventReplicationType eventInvocationType, ENetworkID callingNetworkID, ENetworkID targetNetworkID)
        {
            //Debug.Log("Server_OnBroadcastEvent : " + callingNetworkID + " - " + eventInvocationType);

            if (eventInvocationType == BEventReplicationType.TO_TARGET)
            {
                MirrorBEventDispatcher mirrorBEventDispatcher = (MirrorBEventDispatcher)BEventManager.Instance.BEventDispatcher;
                if (mirrorBEventDispatcher)
                {
                    NetworkIdentity targetNetworkIdentity = mirrorBEventDispatcher.GetNetworkIdentity(targetNetworkID);
                    Target_OnBroadcastEvent(targetNetworkIdentity.connectionToClient, serializedBEHandle, callingNetworkID, targetNetworkID);
                }
            }
            else // ALL or ALL_OTHERS
            {
                Rpc_OnBroadcastEvent(serializedBEHandle, callingNetworkID);
            }
        }
Example #5
0
    public BAnchor SpawnBAnchorAtCursorPosition(BAnchor bAnchorPrefab, bool replicateSpawnToOthers = false)
    {
        if (IS_NOT_NULL(ARCursor.Instance) &&
            IS_NOT_NULL(bAnchorPrefab))
        {
            BAnchor spawnedBAnchor = Instantiate(bAnchorPrefab, ARCursor.Instance.GetCursorPosition(), ARCursor.Instance.GetCursorRotation());
            spawnedBAnchor.Owner = BEventManager.Instance.LocalNetworkID;

            // Trigger event
            BEventReplicationType bEventReplicationType = BEventReplicationType.LOCAL;
            if (replicateSpawnToOthers)
            {
                bEventReplicationType = BEventReplicationType.TO_ALL_OTHERS;
            }
            BEventsCollection.AR_BAnchorSpawned.Invoke(new BEHandle <BAnchorInformation, string>(spawnedBAnchor.GetBAnchorInformation(), spawnedBAnchor.BAnchorID), bEventReplicationType, true);

            return(spawnedBAnchor);
        }
        return(null);
    }
Example #6
0
        public override void OnBEventInvoked <H>(BEvent <H> bEvent, H bEHandle, BEventReplicationType eventInvocationType, ENetworkID targetNetworkID)
        {
            // Broadcast locally if still not connected
            if (LocalNetworkID == ENetworkID.LOCAL)
            {
                bEvent.OnProceedInvokation(bEHandle);
                return;
            }

            switch (eventInvocationType)
            {
            case BEventReplicationType.TO_ALL:
                //Broadcast locally
                bEvent.OnProceedInvokation(bEHandle);

                // Server
                if (LocalNetworkID == ENetworkID.HOST)
                {
                    if (IS_NOT_NULL(LocalMirrorPlayerBEventListener))
                    {
                        // Broadcast it to everyone in connectedNetworkControllers
                        LocalMirrorPlayerBEventListener.Server_RequestBroadcastEvent(bEHandle, eventInvocationType, LocalNetworkID, targetNetworkID);
                    }
                }
                else     // Client
                {
                    if (IS_NOT_NULL(LocalMirrorPlayerBEventListener))
                    {
                        // Send to server, which then broadcasts it to everyone in connectedNetworkControllers
                        LocalMirrorPlayerBEventListener.Client_RequestBroadcastEvent(bEHandle, eventInvocationType, LocalNetworkID, targetNetworkID);
                    }
                }
                break;

            case BEventReplicationType.TO_ALL_OTHERS:
                // Server
                if (LocalNetworkID == ENetworkID.HOST)
                {
                    if (IS_NOT_NULL(LocalMirrorPlayerBEventListener))
                    {
                        // Broadcast it to everyone in connectedNetworkControllers
                        LocalMirrorPlayerBEventListener.Server_RequestBroadcastEvent(bEHandle, eventInvocationType, LocalNetworkID, targetNetworkID);
                    }
                }
                else     // Client
                {
                    if (IS_NOT_NULL(LocalMirrorPlayerBEventListener))
                    {
                        // Send to server, which then broadcasts it to everyone in connectedNetworkControllers
                        LocalMirrorPlayerBEventListener.Client_RequestBroadcastEvent(bEHandle, eventInvocationType, LocalNetworkID, targetNetworkID);
                    }
                }
                break;

            case BEventReplicationType.LOCAL:
                // Broadcast locally
                bEvent.OnProceedInvokation(bEHandle);
                break;

            case BEventReplicationType.TO_TARGET:
                // Server
                if (LocalNetworkID == ENetworkID.HOST)
                {
                    if (IS_NOT_NULL(LocalMirrorPlayerBEventListener))
                    {
                        // Broadcast it to target in connectedNetworkControllers
                        LocalMirrorPlayerBEventListener.Server_RequestBroadcastEvent(bEHandle, eventInvocationType, LocalNetworkID, targetNetworkID);
                    }
                }
                else     // Client
                {
                    if (IS_NOT_NULL(LocalMirrorPlayerBEventListener))
                    {
                        // Send to server, which then broadcasts it to target in connectedNetworkControllers
                        LocalMirrorPlayerBEventListener.Client_RequestBroadcastEvent(bEHandle, eventInvocationType, LocalNetworkID, targetNetworkID);
                    }
                }
                break;
            }
        }
Example #7
0
 public void Invoke(H eventHandle, BEventReplicationType eventInvocationType = BEventReplicationType.LOCAL, bool debugEvent = true, ENetworkID targetNetworkID = ENetworkID.NONE)
 {
     eventHandle.InvokingBEventName = BEventName;
     eventHandle.DebugEvent         = debugEvent;
     BEventManager.Instance.OnBEventInvoked(this, eventHandle, eventInvocationType, targetNetworkID);
 }
Example #8
0
        public override void OnBEventInvoked <H>(BEvent <H> bEvent, H bEHandle, BEventReplicationType eventInvocationType, ENetworkID targetNetworkID)
        {
            //LogConsole(bEvent.BEventName + " : " + bEHandle.GetDebugMessage());

            bEvent.OnProceedInvokation(bEHandle);
        }
Example #9
0
        private void Cmd_OnRequestBroadcastEvent(string serializedBEHandle, BEventReplicationType eventInvocationType, ENetworkID callingNetworkID, ENetworkID targetNetworkID)
        {
            //Debug.Log("Cmd_OnRequestBroadcastEvent : " + callingNetworkID + " - " + eventInvocationType);

            Server_OnBroadcastEvent(serializedBEHandle, eventInvocationType, callingNetworkID, targetNetworkID);
        }
Example #10
0
 public abstract void OnBEventInvoked <H>(BEvent <H> bEvent, H bEHandle, BEventReplicationType eventInvocationType, ENetworkID targetNetworkID) where H : AbstractBEHandle;