private void SESSION_RECEIVE(byte[] _buffer, int _size) { int pos = 0; PacketRead RB_BUFFER = new PacketRead(_buffer, 0); ushort size = RB_BUFFER.UShort(); while (pos < _size) { if (C_Running == false) { return; } if (pos >= _size) { return; } try { byte[] n_buffer = new byte[size]; Array.Copy(_buffer, pos, n_buffer, 0, size); PacketRead r0 = new PacketRead(n_buffer, 0); pos += (ushort)((_buffer[pos + 1] << 8) | (_buffer[pos])); ushort new_size = r0.UShort(); r0.Short(); r0.Int(); byte[] iv = r0.Buffer_Array_Bytes(8); byte[] content = r0.Buffer_Array_Bytes(new_size - 16 - 10); byte[] get_payload = Cryptography.DECRYPT(content, iv); PacketRead rb = new PacketRead(get_payload, 0, true); ushort packetId = (ushort)((get_payload[0] << 8) | (get_payload[1])); if (HRecv.HANDLER.ContainsKey(packetId)) { Log.Write("clog : KTRUser::KSkTRUser::OnRecvCompleted({6}), {0}-{1}-{2}. {3}:{4}:{5}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Second, DateTime.Now.Minute, DateTime.Now.Hour, packetId); Type type = Type.GetType(HRecv.TYPE_HANDLER[packetId].ToString()); object classInstance = Activator.CreateInstance(type, null); HRecv.HANDLER[packetId].Invoke(classInstance, new object[] { this, rb }); } else { Log.Write("clog : KTRUser::KSkTRUser::OnRecvFailed,Packet unknown {6}! {0}-{1}-{2}. {3}:{4}:{5}", DateTime.Now.Year, DateTime.Now.Month, DateTime.Now.Day, DateTime.Now.Second, DateTime.Now.Minute, DateTime.Now.Hour, packetId); Log.Write("\nclog : KTRUser::KSkTRUser::OnRecvFailed, Payload: \n{0}", BitConverter.ToString(get_payload).Replace("-", " ")); PacketWrite p = new PacketWrite(); p.Int(0); SendPacket(p, (short)(packetId + 1)); } } catch (Exception ex) { Log.Write("{0} \n {1}", ex.Message, ex.StackTrace); } } }
public static void KRoomInfo(Session right, PacketRead rs) { libcomservice.REQUEST.Room room = new libcomservice.REQUEST.Room(); ushort m_usRoomID = rs.UShort(); room.m_strRoomName = rs.UnicodeString(); room.m_bPublic = rs.Bool(); room.m_bGuild = rs.Bool(); room.m_strRoomPasswd = rs.UnicodeString(); short m_usUsers = rs.Short(); room.m_usMaxUsers = rs.Get_Short(); room.m_bPlaying = rs.Bool(); room.m_cGrade = rs.Byte(); room.m_cGameCategory = rs.Byte(); room.m_iGameMode = rs.Int(); room.m_iSubGameMode = rs.Int(); room.m_bRandomableMap = rs.Bool(); room.m_iMapID = rs.Int(); room.m_iP2PVersion = rs.Int(); byte[] m_abSlotOpen = rs.Buffer_Array_Bytes(6); room.m_vecMonsterSlot = rs.Int(); room.m_cDifficulty = rs.Int(); rs.Jump(17); ushort index_room = 0; for (ushort i = 1; i < GameServer.m_usMaxUsers; i++) { if (GameServer.List_Rooms.ContainsKey(i)) { continue; } index_room = i; break; } room.m_usRoomID = index_room; room.m_dwSlots[0].Active = true; room.m_dwSlots[0].usr = right; room.m_dwSlots[0].Leader = true; room.m_dwSlots[0].Open = false; room.m_dwSlots[0].Status = 0; room.m_dwSlots[0].AFK = false; room.m_dwSlots[0].Team = 0; for (int i = 1; i < room.m_usMaxUsers; i++) { room.m_dwSlots[i].Active = false; room.m_dwSlots[i].usr = null; room.m_dwSlots[i].Leader = false; room.m_dwSlots[i].Open = true; room.m_dwSlots[i].Status = 0; room.m_dwSlots[i].AFK = false; room.m_dwSlots[i].Team = 0; } right.PInfo.CurRoom = room; }