• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    迪恩网络公众号

C# PeerBase类代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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


示例16: PublishCounterData

        private static void PublishCounterData(PeerBase peer, ICollection<CounterSampleMessage> counterSamples)
        {
            IEnumerable<CounterAggregation> aggregations = CounterAggregation.Create(counterSamples);
            foreach (CounterAggregation aggregation in aggregations)
            {
                var @event = new CounterDataEvent
                    {
                        Name = aggregation.CounterName,
                        TimeStamps = aggregation.Timestamps.ToArray(),
                        Values = aggregation.Values.ToArray()
                    };

                var eventData = new EventData((byte)EventCode.CounterData, @event);

                // already in right fiber, we would use peer.SendEvent otherwise
                peer.SendEvent(eventData, new SendParameters { ChannelId = Settings.DiagnosticsEventChannel });
            }
        }
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:18,代码来源:CounterOperations.cs


示例17: SubscribeCounter

        // The client receives counter updates from the PhotonApplication.CounterPublisher.
        public static OperationResponse SubscribeCounter(PeerBase peer, OperationRequest request)
        {
            var operation = new SubscribeCounter(peer.Protocol, request);
            if (!operation.IsValid)
            {
                return new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage() };
            }

            var mmoPeer = (MmoPeer)peer;
            if (mmoPeer.CounterSubscription == null)
            {
                mmoPeer.CounterSubscription = PhotonApplication.CounterPublisher.Channel.SubscribeToBatch(
                    peer.RequestFiber, m => PublishCounterData(peer, m), operation.ReceiveInterval);

                return operation.GetOperationResponse(MethodReturnValue.Ok);
            }

            return operation.GetOperationResponse((int)ReturnCode.InvalidOperation, "already subscribed");
        }
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:20,代码来源:CounterOperations.cs


示例18: GetRoomReference

        /// <summary>
        /// Gets a room reference for a room with a specified id.
        /// If the room with the specified id does not exists, a new room will be created.
        /// </summary>
        /// <param name="roomName">
        /// The room id.
        /// </param>
        /// <param name="ownerPeer">
        /// The peer that holds this reference.
        /// </param>
        /// <param name="args">
        /// Optionally arguments used for room creation.
        /// </param>
        /// <returns>
        /// a <see cref="RoomReference"/>
        /// </returns>
        public RoomReference GetRoomReference(string roomName, PeerBase ownerPeer, params object[] args)
        {
            lock (this.SyncRoot)
            {
                RoomInstance roomInstance;
                if (!this.RoomInstances.TryGetValue(roomName, out roomInstance))
                {
                    if (log.IsDebugEnabled)
                    {
                        log.DebugFormat("Creating room instance: roomName={0}", roomName);
                    }

                    Room room = this.CreateRoom(roomName, args);
                    roomInstance = new RoomInstance(this, room);
                    this.RoomInstances.Add(roomName, roomInstance);
                }

                return roomInstance.AddReference(ownerPeer);
            }
        }
开发者ID:ommziSolution,项目名称:PhotonServer,代码行数:36,代码来源:RoomCacheBase.cs


示例19: OperationRadarSubscribe

        /// <summary>
        /// Expects operation RadarSubscribe and subscribes the peer to the Radar.
        /// Publishes an OperationResponse with error code ReturnCode.Ok if successful.
        /// </summary>
        public static OperationResponse OperationRadarSubscribe(PeerBase peer, OperationRequest request, SendParameters sendParameters)
        {
            var mmoPeer = (MmoPeer)peer;
            var operation = new RadarSubscribe(peer.Protocol, request);
            if (!operation.IsValid)
            {
                return new OperationResponse(request.OperationCode) { ReturnCode = (int)ReturnCode.InvalidOperationParameter, DebugMessage = operation.GetErrorMessage() };
            }

            if (mmoPeer.RadarSubscription != null)
            {
                mmoPeer.RadarSubscription.Dispose();
                mmoPeer.RadarSubscription = null;
            }

            World world;
            if (WorldCache.Instance.TryGet(operation.WorldName, out world) == false)
            {
                return operation.GetOperationResponse((int)ReturnCode.WorldNotFound, "WorldNotFound");
            }

            mmoPeer.RadarSubscription = world.Radar.Channel.Subscribe(mmoPeer.RequestFiber, m => RadarChannel_OnItemEventMessage(peer, m));

            // set return values
            var responseObject = new RadarSubscribeResponse
                {
                    BoundingBox = world.Area,
                    TileDimensions = world.TileDimensions,
                    WorldName = world.Name
                };

            // send response before sending radar content
            var response = new OperationResponse(request.OperationCode, responseObject);
            peer.SendOperationResponse(response, sendParameters);

            // send complete radar content to client
            world.Radar.SendContentToPeer(mmoPeer);

            // response already sent
            return null;
        }
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:45,代码来源:MmoInitialOperationHandler.cs


示例20: HandleFiendFriends

        private void HandleFiendFriends(PeerBase peer, FindFriendsRequest request, SendParameters sendParameters)
        {
            try
            {
                var onlineList = new bool[request.UserList.Length];
                var gameIds = new string[request.UserList.Length];

                for (int i = 0; i < request.UserList.Length; i++)
                {
                    PlayerState playerState;
                    if (this.playerDict.TryGetValue(request.UserList[i], out playerState))
                    {
                        onlineList[i] = true;
                        if (playerState.ActiveGame != null)
                        {
                            gameIds[i] = playerState.ActiveGame.Id;
                        }
                        else
                        {
                            gameIds[i] = string.Empty;
                        }
                    }
                    else
                    {
                        gameIds[i] = string.Empty;
                    }
                }

                var response = new FindFriendsResponse { IsOnline = onlineList, UserStates = gameIds };
                var opResponse = new OperationResponse((byte)OperationCode.FindFriends, response);
                peer.SendOperationResponse(opResponse, sendParameters);
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
开发者ID:JerryBian,项目名称:PhotonSample,代码行数:37,代码来源:PlayerCache.cs



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C# Pen类代码示例发布时间:2022-05-24
下一篇:
C# Peer类代码示例发布时间:2022-05-24
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap