public void DispatchEvent(int evtType, object parameter = null) { GameEvent GameEvent = CommonObjectPool <GameEvent> .Get(); GameEvent.EventId = evtType; GameEvent.Data = parameter; DispatchEvent(GameEvent); }
/// <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; }
public IProtocol GetProtocol(MemoryStream stream) { var head = CommonObjectPool <ProtocolHead> .Get(); }