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


C# EventData.SendTo方法代码示例

本文整理汇总了C#中EventData.SendTo方法的典型用法代码示例。如果您正苦于以下问题:C# EventData.SendTo方法的具体用法?C# EventData.SendTo怎么用?C# EventData.SendTo使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在EventData的用法示例。


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

示例1: TrySendAmountOfPlayer

 public void TrySendAmountOfPlayer()
 {
     var eventAmountOfPlayer = new EventData((byte)EventCode.AmountOfPlayers);
     int amountOfPlayers = AccountService.Instance.GetAllClient();
     eventAmountOfPlayer.Parameters = new Dictionary<byte, object> { { (byte)ParameterCode.AmountOfPlayer, amountOfPlayers } };
     eventAmountOfPlayer.SendTo(AccountService.Instance.Clients, SendParameters);
 }
开发者ID:AlexGrey,项目名称:MinesServer,代码行数:7,代码来源:ChatInfo.cs

示例2: OnOperationRequest

        protected override void OnOperationRequest(OperationRequest operationRequest, SendParameters sendParameters)
        {
            switch (operationRequest.OperationCode)
            {
                case (byte)OperationCode.Login:
                    var loginRequest = new Login(Protocol, operationRequest);

                    if (!loginRequest.IsValid)
                    {
                        SendOperationResponse(loginRequest.GetResponse(ErrorCode.InvalidParameters), sendParameters);
                        return;
                    }

                    CharacterName = loginRequest.CharacterName;

                    if (World.Instance.IsContain(CharacterName))
                    {
                        SendOperationResponse(loginRequest.GetResponse(ErrorCode.NameIsExist), sendParameters);
                        return;
                    }

                    World.Instance.AddClient(this);

                    var response = new OperationResponse(operationRequest.OperationCode);
                    SendOperationResponse(response, sendParameters);

                    Log.Info("user with name:" + CharacterName);
                    Log.Info("user id:" + ConnectionId);
                    break;

                case (byte)OperationCode.SendChatMessage:
                    {
                        var chatRequest = new ChatMessage(Protocol, operationRequest);

                        if (!chatRequest.IsValid)
                        {
                            SendOperationResponse(chatRequest.GetResponse(ErrorCode.InvalidParameters), sendParameters);
                            return;
                        }

                        string message = chatRequest.Message;

                        string[] param = message.Split(new char[] { ':' }, StringSplitOptions.RemoveEmptyEntries);
                        if (param.Length == 2)
                        {
                            string targetName = param[0];
                            message = param[1];
                            if (World.Instance.IsContain(targetName))
                            {
                                var targetClient = World.Instance.TryGetByName(targetName);
                                if (targetClient == null)
                                    return;

                                message = CharacterName + "[PM]:" + message;

                                var personalEventData = new EventData((byte)EventCode.ChatMessage);
                                personalEventData.Parameters = new Dictionary<byte, object> { { (byte)ParameterCode.ChatMessage, message } };
                                personalEventData.SendTo(new UnityClient[] { this, targetClient }, sendParameters);
                            }
                            return;
                        }

                        message = CharacterName + ": " + message;

                        Chat.Instance.AddMessage(message);

                        var eventData = new EventData((byte)EventCode.ChatMessage);
                        eventData.Parameters = new Dictionary<byte, object> { { (byte)ParameterCode.ChatMessage, message } };
                        eventData.SendTo(World.Instance.Clients, sendParameters);
                    }

                    break;

                case (byte)OperationCode.GetRecentChatMessages:
                    {
                        var messages = Chat.Instance.GetRecentMessages();
                        messages.Reverse();

                        if(messages.Count == 0)
                            break;

                        var message = messages.Aggregate((i, j) => i + "\r\n" + j);
                        var eventData = new EventData((byte)EventCode.ChatMessage);
                        eventData.Parameters = new Dictionary<byte, object> { { (byte)ParameterCode.ChatMessage, message } };
                        eventData.SendTo(new UnityClient[] {this}, sendParameters);
                    }

                    break;

                case (byte)OperationCode.Move:
                    {
                        var moveRequest = new Move(Protocol, operationRequest);

                        if (!moveRequest.IsValid)
                        {
                            SendOperationResponse(moveRequest.GetResponse(ErrorCode.InvalidParameters), sendParameters);
                            return;
                        }

                        Position = new Vector3Net(moveRequest.X, moveRequest.Y, moveRequest.Z);
//.........这里部分代码省略.........
开发者ID:nPaul,项目名称:TestPhotonLib,代码行数:101,代码来源:UnityClient.cs

示例3: WorldExitHandler

 private void WorldExitHandler(SendParameters sendParameters)
 {
     var eventData = new EventData((byte)EventCode.WorldExit);
     eventData.Parameters = new Dictionary<byte, object>
                     {
                         {(byte)ParameterCode.CharacterName, CharacterName}
                     };
     eventData.SendTo(World.Instance.Clients, sendParameters);
 }
开发者ID:nPaul,项目名称:TestPhotonLib,代码行数:9,代码来源:UnityClient.cs

示例4: PublishGameChanges

        public void PublishGameChanges()
        {
            if (this.removedGames.Count == 0 && this.changedGames.Count == 0)
            {
                return;
            }

            foreach (var entry in this.subscriptions)
            {
                Hashtable games;
                if (entry.Key == 0)
                {
                    games = this.GetChangedGames();
                }
                else
                {
                    games = this.GetChangedGames(entry.Key);
                }

                if (games.Count > 0)
                {
                    if (log.IsDebugEnabled)
                    {
                        log.DebugFormat("Publishing game changes: props={0}", this.propertyString);
                    }

                    var e = new GameListUpdateEvent { Data = games };
                    var eventData = new EventData((byte)EventCode.GameListUpdate, e);
                    eventData.SendTo(entry.Value, new SendParameters());
                }
            }

            foreach (var gameId in this.removedGames)
            {
                this.gameDict.Remove(gameId);
            }

            this.changedGames.Clear();
            this.removedGames.Clear();
        }
开发者ID:ommziSolution,项目名称:PhotonServer,代码行数:40,代码来源:GameChannel.cs

示例5: PublishDiscussionEvent

 public void PublishDiscussionEvent(byte eventCode, Dictionary<byte, object> data,
                                    IEnumerable<Actor> actorList,
                                    SendParameters sendParameters)
 {
     IEnumerable<PeerBase> peers = actorList.Select(actor => actor.Peer);
     var eventData = new EventData(eventCode, data);
     eventData.SendTo(peers, sendParameters);
 }
开发者ID:gdlprj,项目名称:duscusys,代码行数:8,代码来源:DiscussionLobby.cs

示例6: PublishGameChanges

        private void PublishGameChanges()
        {
            try
            {
                this.schedule = null;

                if (this.GameList.ChangedGamesCount > 0)
                {
                    Hashtable changedGames = this.GameList.GetChangedGames();

                    var e = new GameListUpdateEvent { Data = changedGames };
                    var eventData = new EventData((byte)EventCode.GameListUpdate, e);
                    eventData.SendTo(this.peers, new SendParameters());
                }
            }
            catch (Exception ex)
            {
                log.Error(ex);
            }
        }
开发者ID:azanium,项目名称:PopBloop-GameServer,代码行数:20,代码来源:AppLobby.cs

示例7: PublishEvent

 /// <summary>
 ///   Publishes an event to a list of actors on a specified channel.
 /// </summary>
 /// <param name = "e">
 ///   The event to publish.
 /// </param>
 /// <param name = "actorList">
 ///   A list of <see cref = "Actor" /> who should receive the event.
 /// </param>
 /// <param name = "sendParameters">
 ///   The send Parameters.
 /// </param>
 protected void PublishEvent(LiteEventBase e, IEnumerable<Actor> actorList, SendParameters sendParameters)
 {
     IEnumerable<PeerBase> peers = actorList.Select(actor => actor.Peer);
     var eventData = new EventData(e.Code, e);
     eventData.SendTo(peers, sendParameters);
 }
开发者ID:gdlprj,项目名称:duscusys,代码行数:18,代码来源:Room.cs

示例8: BroadcastReliableToRoom

 public void BroadcastReliableToRoom(byte eventCode, Dictionary<byte, object> data)
 {
     var eventData = new EventData(eventCode, data);
     var sendParams = new SendParameters();
     eventData.SendTo(Actors.Select(actor => actor.Peer), sendParams);
 }
开发者ID:gdlprj,项目名称:duscusys,代码行数:6,代码来源:DiscussionRoom.cs

示例9: TrySendRecentChatMessage

 public void TrySendRecentChatMessage()
 {
     var eventDataMessages = new EventData((byte)EventCode.ChatMessage);
     string lastMessages = ChatLobby.Instance.GetRecentMessages().Aggregate((i, j) => i + "\r\n" + j);
     eventDataMessages.Parameters = new Dictionary<byte, object> { { (byte)ParameterCode.ChatMessage, lastMessages } };
     eventDataMessages.SendTo(new UnityClient[] { UnityClient }, SendParameters);
 }
开发者ID:AlexGrey,项目名称:MinesServer,代码行数:7,代码来源:ChatInfo.cs

示例10: TrySendChatMessage

        public void TrySendChatMessage()
        {
            var chatRequest = new ChatMessage(UnityClient.Protocol, OperationRequest);

            if (!chatRequest.IsValid) {
                UnityClient.SendOperationResponse(chatRequest.GetResponse(ErrorCode.InvalidParameters), SendParameters);
                return;
            }

            string message = chatRequest.Message;
            message = UnityClient.CharacterName + ": " + message;
            ChatLobby.Instance.AddMessage(message);

            var eventData = new EventData((byte)EventCode.ChatMessage);
            eventData.Parameters = new Dictionary<byte, object>() { { (byte)ParameterCode.ChatMessage, message } };
            eventData.SendTo(AccountService.Instance.Clients, SendParameters);
        }
开发者ID:AlexGrey,项目名称:MinesServer,代码行数:17,代码来源:ChatInfo.cs

示例11: TryEnter

        /// <summary>
        /// 类型:方法
        /// 名称:TryEnter
        /// 作者:taixihuase
        /// 作用:通过角色数据尝试进入场景
        /// 编写日期:2015/7/22
        /// </summary>
        /// <param name="operationRequest"></param>
        /// <param name="sendParameters"></param>
        /// <param name="peer"></param>
        private static void TryEnter(OperationRequest operationRequest, SendParameters sendParameters, ServerPeer peer)
        {
            ServerPeer.Log.Debug("Entering");

            int uniqueId = (int)
                Serialization.Deserialize(operationRequest.Parameters[(byte) ParameterCode.WorldEnter]);

            Character character;
            if (peer.Server.Characters.CharacterEnter(uniqueId, out character))
            {
                peer.Server.Data.CharacterData.GetCharacterPosition(character);
            }

            // 返回数据给客户端

            byte[] pos = Serialization.Serialize(character.Position);

            OperationResponse reponseData = new OperationResponse((byte) OperationCode.WorldEnter,
                new Dictionary<byte, object>
                {
                    {(byte) ParameterCode.WorldEnter, pos}
                })
            {
                ReturnCode = (short) ErrorCode.Ok,
                DebugMessage = "进入场景成功"
            };
            peer.SendOperationResponse(reponseData, sendParameters);

            byte[] data = Serialization.Serialize(character);
            EventData eventData = new EventData((byte) EventCode.WorldEnter, new Dictionary<byte, object>
            {
                {(byte) ParameterCode.WorldEnter, data}
            });
            eventData.SendTo(peer.Server.Characters.GamingClientsToBroadcast, sendParameters);
        }
开发者ID:taixihuase,项目名称:SiegeOnline,代码行数:45,代码来源:WorldEnter.cs


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