/* 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); } }
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); }
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; } }
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); } }
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); }
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; } }
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); }
public override void OnBEventInvoked <H>(BEvent <H> bEvent, H bEHandle, BEventReplicationType eventInvocationType, ENetworkID targetNetworkID) { //LogConsole(bEvent.BEventName + " : " + bEHandle.GetDebugMessage()); bEvent.OnProceedInvokation(bEHandle); }
private void Cmd_OnRequestBroadcastEvent(string serializedBEHandle, BEventReplicationType eventInvocationType, ENetworkID callingNetworkID, ENetworkID targetNetworkID) { //Debug.Log("Cmd_OnRequestBroadcastEvent : " + callingNetworkID + " - " + eventInvocationType); Server_OnBroadcastEvent(serializedBEHandle, eventInvocationType, callingNetworkID, targetNetworkID); }
public abstract void OnBEventInvoked <H>(BEvent <H> bEvent, H bEHandle, BEventReplicationType eventInvocationType, ENetworkID targetNetworkID) where H : AbstractBEHandle;