Exemplo n.º 1
0
    public void DispatchEvent(int evtType, object parameter = null)
    {
        GameEvent GameEvent = CommonObjectPool <GameEvent> .Get();

        GameEvent.EventId = evtType;
        GameEvent.Data    = parameter;
        DispatchEvent(GameEvent);
    }
Exemplo n.º 2
0
        /// <summary>
        /// 序列化为Package
        /// </summary>
        /// <param name="stream"></param>
        public void SerializePackage(MemoryStream stream)
        {
            stream.SetLength(0);
            stream.Position = 0;

            var begin = stream.Position;
            var head  = CommonObjectPool <ProtocolHead> .Get();

            head.length    = 0;
            head.messageId = MessageId;
            head.Serialize(stream);

            Serialize(stream);
            long position = stream.Position;
            int  length   = (int)(position - begin);

            //重写长度头
            stream.Position = begin;
            stream.Write(BitConverter.GetBytes(length), 0, 4);
            stream.Position = position;
        }
Exemplo n.º 3
0
 public IProtocol GetProtocol(MemoryStream stream)
 {
     var head = CommonObjectPool <ProtocolHead> .Get();
 }