public ProtocolItem(int protocolId, byte[] bytes) { ProtocolId = protocolId; byte[] enryptByteArray; MBinaryWriter mbw = new MBinaryWriter(); if (!Game.GameConfig.instance.encrypt) { if (bytes == null) { mbw.Write(ProtocolConf.PROTOCOL_HEAD_LENGTH); } else { mbw.Write(bytes.Length + ProtocolConf.PROTOCOL_HEAD_LENGTH); } } mbw.Write(ProtocolProxy.instance.Version); mbw.Write(ProtocolProxy.instance.UserID0); mbw.Write(ProtocolProxy.instance.UserID1); mbw.Write(ProtocolProxy.instance.UserID2); mbw.Write(ProtocolProxy.instance.UserID3); mbw.Write(ProtocolProxy.instance.UserID4); mbw.Write(ProtocolProxy.instance.UserID5); mbw.Write(TimeController.instance.ServerTimeTicksMillisecondAfter9); mbw.Write(ProtocolProxy.instance.UserID7); mbw.Write(ProtocolId); if (bytes != null) { mbw.Write(bytes); } if (Game.GameConfig.instance.encrypt) { enryptByteArray = Common.Util.EncryptUtil.AESEncryptBytes(mbw.ToArray(), Game.GameConfig.instance.aesEncryptKey); mbw.Clear(); mbw.Write(enryptByteArray.Length); mbw.Write(enryptByteArray); } ProtocolItemBytes = mbw.ToArray(); mbw.Close(); mbw = null; if (ProtocolConf.NeedShowMask(ProtocolId)) { Logic.UI.Mask.Contorller.MaskController.instance.ShowMask(); } }
public ProtocolItem(int protocolId, ProtoBuf.IExtensible protocol) { if (protocol != null) { if (ProtocolProxy.instance.IsLoginServer) { ProtocolId = (int)ProtocolConf.GetLoginServerIdByType(protocol.GetType()); } else { ProtocolId = protocolId; } Protocol = protocol; ProtocolItemBytes = ParseItem(); if (ProtocolConf.NeedShowMask(ProtocolId)) { Logic.UI.Mask.Contorller.MaskController.instance.ShowMask(); } } }