protected void WrapClientPeer(IClientPeer clientPeer, IPeerLogicBase peerLogic)
        {
            var idGenerator = ServerComponents.GetComponent <IIdGenerator>().AssertNotNull();
            var peerId      = idGenerator.GenerateId();

            var clientPeerWrapper = new ClientPeerWrapper(clientPeer, peerId);

            clientPeerWrapper.SetPeerLogic(peerLogic);

            peerContainer.AddPeerLogic(clientPeerWrapper);
        }
        public void SetPeerLogic <TPeerLogic>(TPeerLogic peerLogic)
            where TPeerLogic : IPeerLogicBase
        {
            Peer.Fiber.Enqueue(() =>
            {
                Peer.NetworkTrafficState = NetworkTrafficState.Paused;

                PeerLogic?.Dispose();
                PeerLogic = peerLogic;
                PeerLogic.Initialize(this);

                Peer.NetworkTrafficState = NetworkTrafficState.Flowing;
            });
        }
Пример #3
0
        public void SetPeerLogic <T, TOperationCode, TEventCode>()
            where T : IPeerLogicBase, new()
            where TOperationCode : IComparable, IFormattable, IConvertible
            where TEventCode : IComparable, IFormattable, IConvertible
        {
            peerLogicBase?.Dispose();
            serverPeerHandler?.Dispose();

            var peerHandler = new ServerPeerHandler <TOperationCode, TEventCode>();

            peerHandler.Initialize(ServiceConnectionHandler.ServerPeer ?? new PhotonPeer());
            serverPeerHandler = peerHandler;

            peerLogicBase = new T();
            peerLogicBase.Awake(serverPeerHandler);
        }