void PacketInterface.encode() { PacketUtil.encodeHeader(packet_, this.type()); PacketUtil.encode(packet_, clientId_); PacketUtil.encode(packet_, id_); PacketUtil.encode(packet_, password_); }
public void receive() { if (stream_.DataAvailable) { Byte[] packetByte = new Byte[client_.ReceiveBufferSize]; Int32 offset = 0; Int32 readLen = stream_.Read(packetByte, offset, packetByte.Length); PacketObfuscation.decodingHeader(ref packetByte, sizeof(Int32)); Int32 packetLen = PacketUtil.decodePacketLen(packetByte, ref offset); while (readLen < packetLen) { Byte[] remainPacket = new Byte[client_.ReceiveBufferSize]; Int32 remainLen = 0; remainLen = stream_.Read(remainPacket, 0, remainPacket.Length); Buffer.BlockCopy(remainPacket, 0, packetByte, readLen, remainLen); readLen += remainLen; } Byte[] packetData = new Byte[client_.ReceiveBufferSize]; Buffer.BlockCopy(packetByte, offset, packetData, 0, readLen - offset); PacketObfuscation.decodingData(ref packetData, packetData.Length); PacketInterface rowPacket = PacketUtil.packetAnalyzer(packetData); if (rowPacket == null && this.isConnected()) { Debug.Log("잘못된 패킷이 수신되었습니다"); } packetProcee_.run(rowPacket); } }
void PacketInterface.encode() { PacketUtil.encodeHeader(packet_, this.type()); PacketUtil.encode(packet_, ip_); PacketUtil.encode(packet_, port_); PacketUtil.encode(packet_, name_); }
void PacketInterface.encode() { PacketUtil.encodeHeader(packet_, this.type()); PacketUtil.encode(packet_, clientId_); PacketUtil.encode(packet_, name_); PacketUtil.encode(packet_, result_); }
public static string decodestring(Byte[] data, ref Int32 offset) { Int32 strLen = PacketUtil.decodeInt32(data, ref offset); string str = System.Text.Encoding.ASCII.GetString(data, offset, strLen); offset += strLen; return(str); }
public static PacketInterface packetAnalyzer(Byte[] packetByte) { Int32 offset = 0; Int64 packetType = PacketUtil.decodePacketType(packetByte, ref offset); PacketInterface packet = PacketFactory.getPacket(packetType); if (packet == null) { return(null); } // 데이터가 있으면 decoding 해서 넘기기 if (offset < packetByte.Length) { packet.decode(packetByte, ref offset); } return(packet); }
void PacketInterface.decode(byte[] packet, ref int offset) { roomNum = PacketUtil.decodeUInt64(packet, ref offset); }
public static Int64 decodePacketType(Byte[] data, ref Int32 offset) { return(PacketUtil.decodeInt64(data, ref offset)); }
//-------------------------------------------------------------------// //---decoding 부분 public static Int32 decodePacketLen(Byte[] data, ref Int32 offset) { return(PacketUtil.decodeInt32(data, ref offset)); }
public static void encode(MemoryStream packet, string str) { PacketUtil.encode(packet, (Int32)str.Length); packet.Write(Encoding.UTF8.GetBytes(str), 0, str.Length); }
//-------------------------------------------------------------------// //--- encodeing 부분 public static void encodeHeader(MemoryStream packet, Int64 headerType) { PacketUtil.encode(packet, headerType); }
void PacketInterface.encode() { PacketUtil.encodeHeader(packet_, this.type()); }
void PacketInterface.decode(byte[] packet, ref int offset) { ip_ = PacketUtil.decodestring(packet, ref offset); port_ = PacketUtil.decodeUInt32(packet, ref offset); name_ = PacketUtil.decodestring(packet, ref offset); }
void PacketInterface.decode(byte[] packet, ref int offset) { name_ = PacketUtil.decodestring(packet, ref offset); }
void PacketInterface.decode(byte[] packet, ref int offset) { clientId_ = PacketUtil.decodeUInt64(packet, ref offset); name_ = PacketUtil.decodestring(packet, ref offset); result_ = PacketUtil.decodeByte(packet, ref offset); }
void PacketInterface.decode(byte[] packet, ref int offset) { clientId_ = PacketUtil.decodeUInt64(packet, ref offset); oidAccountId_ = PacketUtil.decodeUInt64(packet, ref offset); }
void PacketInterface.encode() { PacketUtil.encodeHeader(packet_, this.type()); PacketUtil.encode(packet_, clientId_); PacketUtil.encode(packet_, oidAccountId_); }
void PacketInterface.decode(byte[] packet, ref int offset) { clientId_ = PacketUtil.decodeUInt64(packet, ref offset); id_ = PacketUtil.decodestring(packet, ref offset); password_ = PacketUtil.decodestring(packet, ref offset); }