当前位置: 首页>>代码示例>>C#>>正文


C# PeerBase类代码示例

本文整理汇总了C#中PeerBase的典型用法代码示例。如果您正苦于以下问题:C# PeerBase类的具体用法?C# PeerBase怎么用?C# PeerBase使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


PeerBase类属于命名空间,在下文中一共展示了PeerBase类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: RoomReference

 /// <summary>
 /// Initializes a new instance of the <see cref="RoomReference"/> class.
 /// </summary>
 /// <param name="roomCache">
 /// The room cache.
 /// </param>
 /// <param name="room">
 /// The room.
 /// </param>
 public RoomReference(RoomCacheBase roomCache, Room room, PeerBase ownerPeer)
 {
     this.roomCache = roomCache;
     this.id = Guid.NewGuid();
     this.Room = room;
     this.ownerPeer = ownerPeer;
 }
开发者ID:rsandrini,项目名称:WarkanaServer,代码行数:16,代码来源:RoomReference.cs

示例2: Actor

 /// <summary>
 ///   Initializes a new instance of the <see cref = "Actor" /> class.
 /// </summary>
 /// <param name = "peer">
 ///   The owner peer.
 /// </param>
 /// <param name = "world">
 ///   The world.
 /// </param>
 protected Actor(PeerBase peer, IWorld world)
 {
     this.peer = peer;
     this.world = world;
     this.ownedItems = new Dictionary<byte, Dictionary<string, Item>>();
     this.interestAreas = new Dictionary<byte, InterestArea>();
 }
开发者ID:ommziSolution,项目名称:PhotonServer,代码行数:16,代码来源:Actor.cs

示例3: MmoActor

 protected MmoActor(PeerBase peer, World world)
 {
     this.peer = peer;
     this.world = world;
     this.interestAreas = new Dictionary<byte, InterestArea>();
     this.interestItems = new InterestItems(peer);
 }
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:7,代码来源:MmoActor.cs

示例4: AddSubscription

        public Subscription AddSubscription(PeerBase peer, int gameCount)
        {
            if (log.IsDebugEnabled)
            {
                log.DebugFormat("New Subscription: pid={0}, gc={1}, props={2}", peer.ConnectionId, gameCount, this.propertyString);
            }

            if (gameCount < 0)
            {
                gameCount = 0;
            }

            var subscription = new Subscription(this, peer, gameCount);
            HashSet<PeerBase> hashSet;
            if (this.subscriptions.TryGetValue(gameCount, out hashSet) == false)
            {
                if (log.IsDebugEnabled)
                {
                    log.DebugFormat("Creating new hashset for game count = {0}", gameCount);
                }

                hashSet = new HashSet<PeerBase>();
                this.subscriptions.Add(gameCount, hashSet);
            }

            hashSet.Add(peer);
            return subscription;
        }
开发者ID:ommziSolution,项目名称:PhotonServer,代码行数:28,代码来源:GameChannel.cs

示例5: PeerDisconnected

 public void PeerDisconnected(PeerBase peer)
 {
     lock (Connections)
     {
         Connections.Remove(peer);
     }
 }
开发者ID:anhle128,项目名称:demo_photon_with_unity,代码行数:7,代码来源:PhotonAckGame.cs

示例6: PeerConnected

 public void PeerConnected(PeerBase peer)
 {
     lock(Connections)
     {
         Connections.Add(peer);
     }
 }
开发者ID:anhle128,项目名称:demo_photon_with_unity,代码行数:7,代码来源:PhotonAckGame.cs

示例7: ClientInterestArea

 /// <summary>
 ///   Initializes a new instance of the <see cref = "ClientInterestArea" /> class.
 /// </summary>
 /// <param name = "peer">
 ///   The peer.
 /// </param>
 /// <param name = "id">
 ///   The id for this interest area. 
 ///   Unique per <see cref = "Actor" />.
 /// </param>
 /// <param name = "world">
 ///   The <see cref = "IWorld" /> this interest area is watching.
 /// </param>
 /// <param name = "fiber">
 ///   The fiber this intereast receives events on.
 /// </param>
 public ClientInterestArea(PeerBase peer, byte id, IWorld world, IFiber fiber)
     : base(id, world)
 {
     this.peer = peer;
     this.eventChannelSubscriptions = new Dictionary<Item, IDisposable>();
     this.fiber = fiber;
 }
开发者ID:ommziSolution,项目名称:PhotonServer,代码行数:23,代码来源:ClientInterestArea.cs

示例8: OnDisconnectByOtherPeer

        /// <summary>
        /// Kicks the actor from the world (event WorldExited is sent to the client) and then disconnects the client.
        /// </summary>
        /// <remarks>
        /// Called by DisconnectByOtherPeer after being enqueued to the PeerBase.RequestFiber.
        /// It kicks the actor from the world (event WorldExited) and then continues the original request by calling the original peer's OnOperationRequest method.        
        /// </remarks>
        public void OnDisconnectByOtherPeer(PeerBase otherPeer, OperationRequest otherRequest, SendParameters sendParameters)
        {
            this.ExitWorld();

            // disconnect peer after the exit world event is sent
            this.Peer.RequestFiber.Enqueue(() => this.Peer.RequestFiber.Enqueue(this.Peer.Disconnect));

            // continue execution of other request
            PeerHelper.InvokeOnOperationRequest(otherPeer, otherRequest, sendParameters);
        }
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:17,代码来源:MmoActorOperationHandler.cs

示例9: SocketUdpNativeDllImport

        public SocketUdpNativeDllImport(PeerBase npeer) : base(npeer)
        {
            if (this.ReportDebugOfLevel(DebugLevel.ALL))
            {
                this.Listener.DebugReturn(DebugLevel.ALL, "SocketWrapper: UDP, Unity Android Native.");
            }

            this.Protocol = ConnectionProtocol.Udp;
            this.PollReceive = false;
        }
开发者ID:reaganq,项目名称:MagnetBots_unity,代码行数:10,代码来源:SocketUdpNativeDllImport.cs

示例10: SocketUdp

        public SocketUdp(PeerBase npeer) : base(npeer)
        {
            if (this.ReportDebugOfLevel(DebugLevel.ALL))
            {
                this.Listener.DebugReturn(DebugLevel.ALL, "CSharpSocket: UDP, Unity3d.");
            }

            this.Protocol = ConnectionProtocol.Udp;
            this.PollReceive = false;
        }
开发者ID:SHEePYTaGGeRNeP,项目名称:FontysMobileGameJam,代码行数:10,代码来源:SocketUdp.cs

示例11: SocketWebTcp

        public SocketWebTcp(PeerBase npeer) : base(npeer)
        {
            ServerAddress = npeer.ServerAddress;
            if (this.ReportDebugOfLevel(DebugLevel.INFO))
            {
                Listener.DebugReturn(DebugLevel.INFO, "new SocketWebTcp() " + ServerAddress);
            }

            Protocol = ConnectionProtocol.Tcp;
            PollReceive = false;
        }
开发者ID:ly774508966,项目名称:IUILab_Lecture_KinectAndOculusWithUnity3D,代码行数:11,代码来源:SocketWebTcp.cs

示例12: UnsubscribeCounter

        /// <summary>
        /// The client stops receiving counter updates from the PhotonApplication.CounterPublisher.
        /// </summary>
        public static OperationResponse UnsubscribeCounter(PeerBase peer, OperationRequest request)
        {
            var mmoPeer = (MmoPeer)peer;
            if (mmoPeer.CounterSubscription == null)
            {
                return new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.InvalidOperation, DebugMessage = "not subscribed" };
            }

            mmoPeer.CounterSubscription.Dispose();
            mmoPeer.CounterSubscription = null;
            return new OperationResponse(request.OperationCode);
        }
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:15,代码来源:CounterOperations.cs

示例13: OperationEnterWorld

        public OperationResponse OperationEnterWorld(PeerBase peer, OperationRequest request, SendParameters sendParameters)
        {
            var operation = new EnterWorld(peer.Protocol, request);
            if (!operation.IsValid)
            {
                return new OperationResponse(request.OperationCode) { ReturnCode = (int)ErrorCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage() };
            }

            MmoWorld world = MmoWorld.Instance;

            var actor = new MmoActor(peer, world, interestArea);
            var avatar = new MmoItem(world, operation.Position, operation.Rotation, operation.Properties, actor, operation.Username, (byte)ItemType.Avatar);

            while (world.ItemCache.AddItem(avatar) == false)
            {
                Item otherAvatarItem;
                if (world.ItemCache.TryGetItem(avatar.Type, avatar.Id, out otherAvatarItem))
                {
                    avatar.Dispose();
                    actor.Dispose();
                    interestArea.Dispose();

                    ((Peer)((MmoItem)otherAvatarItem).Owner.Peer).DisconnectByOtherPeer(this, request, sendParameters);

                    // request continued later, no response here
                    return null;
                }
            }

            // init avatar
            actor.AddItem(avatar);
            actor.Avatar = avatar;

            ((Peer)peer).SetCurrentOperationHandler(actor);

            // set return values
            var responseObject = new EnterWorldResponse
            {
            };

            // send response; use item channel to ensure that this event arrives before any move or subscribe events
            var response = new OperationResponse(request.OperationCode, responseObject);
            sendParameters.ChannelId = Settings.ItemEventChannel;
            peer.SendOperationResponse(response, sendParameters);

            avatar.Spawn(operation.Position);

            // response already sent
            return null;
        }
开发者ID:valentin-bas,项目名称:PhotonGame,代码行数:50,代码来源:MmoPeer.cs

示例14: AddSubscription

        public override IGameListSubscription AddSubscription(PeerBase peer, Hashtable gamePropertyFilter, int maxGameCount)
        {
            if (gamePropertyFilter == null)
            {
                gamePropertyFilter = new Hashtable(0);
            }

            GameChannel gameChannel;
            var key = new GameChannelKey(gamePropertyFilter);

            if (!this.GameChannels.TryGetValue(key, out gameChannel))
            {
                gameChannel = new GameChannel(this, key);
                this.GameChannels.Add(key, gameChannel);
            }

            return gameChannel.AddSubscription(peer, maxGameCount);
        }
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:18,代码来源:GameChannelList.cs

示例15: OnOperationRequest

        public OperationResponse OnOperationRequest(PeerBase peer, OperationRequest operationRequest, SendParameters sendParameters)
        {
            switch ((OperationCode)operationRequest.OperationCode)
            {
                case OperationCode.EnterWorld:
                    return this.OperationEnterWorld(peer, operationRequest, sendParameters);

                case OperationCode.ExitWorld:
                case OperationCode.Move:
                    return InvalidOperation(operationRequest);
            }

            return new OperationResponse(operationRequest.OperationCode)
            {
                ReturnCode = (int)ErrorCode.OperationNotSupported,
                DebugMessage = "OperationNotSupported: " + operationRequest.OperationCode
            };
        }
开发者ID:valentin-bas,项目名称:PhotonGame,代码行数:18,代码来源:MmoPeer.cs


注:本文中的PeerBase类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。