示例#1
0
        public override void Clear(StreamBuffer source)
        {
            Int32 seqNo = SeqNo;

            base.Clear(source);
            SeqNo = seqNo;
        }
示例#2
0
        public static Int32 GetSeqNo(StreamBuffer source)
        {
            if (source.BufferSize < HeaderSize)
                return -1;

            return source.GetInt32(Packet.HeaderSize);
        }
示例#3
0
        public SpriteQuad(Device device, int maxInstances) : base(device)
        {
            int slot = 0;
            AddVetexStreamBuffer(new VertexStreamBuffer<SpriteVertex>(InternalDevice, 
                                                                      CreateQuadVertices(), 
                                                                      slot, 
                                                                      ResourceUsage.Default), 
                                                                      CreateInputElements());

         
            AddIndexStreamBuffer(CreateIndices());

            int totalBufferSize = 16;/* FIX ME: Size needs to be multiples of 16... or is it 8? */
            m_vertexBatchConstantBuffer = new ConstantStreamBuffer<VertexConstantData>(InternalDevice,
                                                                                       totalBufferSize,
                                                                                       0, 
                                                                                       ConstantStreamBufferType.VertexShader,
                                                                                       ResourceUsage.Dynamic,
                                                                                       CpuAccessFlags.Write);

            m_streamBuffers.Add(m_vertexBatchConstantBuffer);

            totalBufferSize = Marshal.SizeOf(typeof(SpriteDrawData)) * maxInstances;
            slot = 1;
            m_instanceDataStream = new VertexStreamBuffer<SpriteDrawData>(device,
                                                                          totalBufferSize,
                                                                          slot,
                                                                          ResourceUsage.Dynamic,
                                                                          CpuAccessFlags.Write);

            m_streamBuffers.Add(m_instanceDataStream);
        }
示例#4
0
        public static new Boolean IsValidPacket(StreamBuffer buffer, out int packetSize)
        {
            if (buffer.WrittenBytes < HeaderSize)
            {
                packetSize = 0;
                return false;
            }

            packetSize = buffer.GetUInt16();
            return (packetSize > 0 && buffer.WrittenBytes >= packetSize);
        }
示例#5
0
    private static short SerializeVector2(StreamBuffer outStream, object customobject)
    {
        Vector2 vo = (Vector2)customobject;
        lock (memVector2)
        {
            byte[] bytes = memVector2;
            int index = 0;
            Protocol.Serialize(vo.x, bytes, ref index);
            Protocol.Serialize(vo.y, bytes, ref index);
            outStream.Write(bytes, 0, 2 * 4);
        }

        return 2 * 4;
    }
示例#6
0
    private static object DeserializeVector3(StreamBuffer inStream, short length)
    {
        Vector3 vo = new Vector3();
        lock (memVector3)
        {
            inStream.Read(memVector3, 0, 3 * 4);
            int index = 0;
            Protocol.Deserialize(out vo.x, memVector3, ref index);
            Protocol.Deserialize(out vo.y, memVector3, ref index);
            Protocol.Deserialize(out vo.z, memVector3, ref index);
        }

        return vo;
    }
        public Boolean Dispatch(StreamBuffer buffer)
        {
            foreach (var data in _listResponseAction)
            {
                if (data.Criterion(buffer) == true)
                {
                    try
                    {
                        _listResponseAction.Remove(data);
                        data.Dispatcher(_session, buffer);
                    }
                    catch (Exception e)
                    {
                        Logger.Write(LogType.Err, 1, e.ToString());
                    }
                    return true;
                }
            }

            return false;
        }
示例#8
0
    private static object DeserializeQuaternion(StreamBuffer inStream, short length)
    {
        Quaternion o = new Quaternion();

        lock (memQuarternion)
        {
            inStream.Read(memQuarternion, 0, 4 * 4);
            int index = 0;
            Protocol.Deserialize(out o.w, memQuarternion, ref index);
            Protocol.Deserialize(out o.x, memQuarternion, ref index);
            Protocol.Deserialize(out o.y, memQuarternion, ref index);
            Protocol.Deserialize(out o.z, memQuarternion, ref index);
        }

        return o;
    }
示例#9
0
 public NetworkSendToken(StreamBuffer buffer, Action<StreamBuffer> completion)
 {
     Buffer = buffer;
     _actionOnCompletion = completion;
 }
示例#10
0
 /// <summary>
 /// 패킷을 전송합니다.
 /// </summary>
 /// <param name="buffer">전송할 데이터가 담긴 StreamBuffer</param>
 /// <param name="onSent">패킷 전송이 완료된 후 호출할 Action</param>
 public virtual void SendPacket(StreamBuffer buffer, Action<StreamBuffer> onSent = null)
 {
     _method.SendPacket(buffer, onSent);
 }
示例#11
0
 /// <summary>
 /// StreamBuffer의 데이터를 복사하여 패킷을 생성합니다.
 /// </summary>
 /// <param name="source">복사할 데이터가 담긴 StreamBuffer 객체</param>
 public SecurityPacket(StreamBuffer source)
 {
     Write(source.Buffer, 0, source.WrittenBytes);
 }
示例#12
0
        /// <summary>
        /// 패킷 버퍼를 초기화하고 source 데이터를 저장합니다. Packet Header의 Size는 source 버퍼의 헤더값이 사용됩니다.
        /// </summary>
        /// <param name="source">저장할 데이터</param>
        public void Clear(StreamBuffer source)
        {
            if (source.BufferSize < 4)
                throw new AegisException(ResultCode.InvalidArgument, "The source size must be at lest 4 bytes.");

            base.Clear();
            Write(source.Buffer, 0, source.WrittenBytes);
            Size = GetUInt16(0);
        }
示例#13
0
 internal void OnReceived(StreamBuffer buffer)
 {
     StreamBuffer buf = new StreamBuffer(buffer);
     SpinWorker.Dispatch(() =>
     {
         if (NetworkEvent_Received != null)
             NetworkEvent_Received(this, buf);
     });
 }
示例#14
0
 /// <summary>
 /// 패킷을 전송하고, 특정 패킷이 수신될 경우 dispatcher에 지정된 핸들러를 실행합니다.
 /// 이 기능은 AwaitableMethod보다는 빠르지만, 동시에 많이 호출될 경우 성능이 저하될 수 있습니다.
 /// </summary>
 /// <param name="buffer">전송할 데이터가 담긴 StreamBuffer</param>
 /// <param name="criterion">dispatcher에 지정된 핸들러를 호출할 것인지 여부를 판단하는 함수를 지정합니다.</param>
 /// <param name="dispatcher">실행될 함수를 지정합니다.</param>
 /// <param name="onSent">패킷 전송이 완료된 후 호출할 Action</param>
 public virtual void SendPacket(StreamBuffer buffer, PacketCriterion criterion, EventHandler_Receive dispatcher, Action<StreamBuffer> onSent = null)
 {
     _method.SendPacket(buffer, criterion, dispatcher, onSent);
 }
示例#15
0
    private static object DeserializePhotonPlayer(StreamBuffer inStream, short length)
    {
        int ID;
        lock (memPlayer)
        {
            inStream.Read(memPlayer, 0, length);
            int off = 0;
            Protocol.Deserialize(out ID, memPlayer, ref off);
        }

        if (PhotonNetwork.networkingPeer.mActors.ContainsKey(ID))
        {
            return PhotonNetwork.networkingPeer.mActors[ID];
        }
        else
        {
            return null;
        }
    }
示例#16
0
 public PacketResponse(StreamBuffer source)
     : base(source)
 {
 }
示例#17
0
 public void SendPacket(StreamBuffer buffer, Action<StreamBuffer> onSent = null)
 {
     Session?.SendPacket(buffer, onSent);
 }
示例#18
0
    private static short SerializeQuaternion(StreamBuffer outStream, object customobject)
    {
        Quaternion o = (Quaternion)customobject;

        lock (memQuarternion)
        {
            byte[] bytes = memQuarternion;
            int index = 0;
            Protocol.Serialize(o.w, bytes, ref index);
            Protocol.Serialize(o.x, bytes, ref index);
            Protocol.Serialize(o.y, bytes, ref index);
            Protocol.Serialize(o.z, bytes, ref index);
            outStream.Write(bytes, 0, 4 * 4);
        }

        return 4 * 4;
    }
示例#19
0
        /// <summary>
        /// 수신된 데이터가 유효한 패킷인지 여부를 확인합니다.
        /// 유효한 패킷으로 판단되면 packetSize에 이 패킷의 정확한 크기를 입력하고 true를 반환해야 합니다.
        /// </summary>
        /// <param name="buffer">수신된 데이터가 담긴 버퍼</param>
        /// <param name="packetSize">유효한 패킷의 크기</param>
        /// <returns>true를 반환하면 OnReceive를 통해 수신된 데이터가 전달됩니다.</returns>
        public static Boolean IsValidPacket(StreamBuffer buffer, out Int32 packetSize)
        {
            if (buffer.WrittenBytes < HeaderSize)
            {
                packetSize = 0;
                return false;
            }

            //  최초 2바이트를 수신할 패킷의 크기로 처리
            packetSize = buffer.GetUInt16(0);
            return (packetSize > 0 && buffer.WrittenBytes >= packetSize);
        }
示例#20
0
    private static short SerializePhotonPlayer(StreamBuffer outStream, object customobject)
    {
        int ID = ((PhotonPlayer)customobject).ID;

        lock (memPlayer)
        {
            byte[] bytes = memPlayer;
            int off = 0;
            Protocol.Serialize(ID, bytes, ref off);
            outStream.Write(bytes, 0, 4);
            return 4;
        }
    }
示例#21
0
        public IStreamBuffer CreateStreamBuffer(TsStreamType streamType)
        {
            ThrowIfDisposed();

            var buffer = new StreamBuffer(streamType, _packetPool.FreePesPacket, this);

            lock (_lock)
            {
                _queues.Add(buffer);

                ResizeStatuses();
            }

            return buffer;
        }