コード例 #1
0
        //--------------------------------------------------------------------------------------------------------------------------------------------

        //--------------------------------------------------------------------------------------------------------------------------------------------

        /// <summary>
        /// 战斗协议 ClientBattleAction 直接发往AreaService
        /// </summary>
        /// <param name="action"></param>
        public virtual void SendToArea(TypeCodec route_codec, BinaryMessage action)
        {
            try
            {
                var area  = remote_area_service;
                var enter = enter_game;
                if (area != null && enter != null)
                {
                    using (var output = IOStreamObjectPool.AllocOutputAutoRelease(ConnectServer.ClientCodec.Factory))
                    {
                        output.PutUTF(enter.c2s_roleUUID);
                        output.PutBytes(action.Buffer, action.BufferOffset, action.BufferLength);
                        var to_area = BinaryMessage.FromBuffer(session_battle_action_codec.MessageID, output.Buffer);
                        area.WormholeTransport(to_area);
                    }
                }
            }
            catch (Exception err)
            {
                log.Error(err);
            }
        }
コード例 #2
0
 public virtual void client_rpc_Handle(BinaryMessage action)
 {
     try
     {
         using (var buffer = MemoryStreamObjectPool.AllocAutoRelease(action.DataSegment))
             using (var input = IOStreamObjectPool.AllocInputAutoRelease(base.ServerCodec.Factory, buffer))
             {
                 var roleID = input.GetUTF();
                 var player = GetPlayer(roleID);
                 if (player == null)
                 {
                     return;
                 }
                 //drop 4 for bytes size//
                 buffer.Position += 4;
                 player.client_rpc_Handle(buffer);
             }
     }
     catch (Exception e)
     {
         log.Error(e.Message, e);
     }
 }