Skip to content

Commit

Permalink
Merge pull request #11 from KwDrama/feature-selfchat
Browse files Browse the repository at this point in the history
Feature selfchat
  • Loading branch information
geoje authored May 31, 2021
2 parents edf35fc + 0078cdf commit 4ff4905
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 12 deletions.
2 changes: 1 addition & 1 deletion Client/Client.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@
<GenerateManifests>true</GenerateManifests>
</PropertyGroup>
<PropertyGroup>
<SignManifests>true</SignManifests>
<SignManifests>false</SignManifests>
</PropertyGroup>
<ItemGroup>
<Reference Include="MetroFramework, Version=1.4.0.0, Culture=neutral, PublicKeyToken=5f91a84759bf584a, processorArchitecture=MSIL">
Expand Down
2 changes: 2 additions & 0 deletions Client/Forms/FormRoom.cs
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,8 @@ private void txtChat_KeyDown(object sender, KeyEventArgs e)
e.SuppressKeyPress = true;
picSend_Click(sender, new EventArgs());
}
else if (e.KeyCode == Keys.Escape)
Close();
}
private void picSend_Click(object sender, EventArgs e)
{
Expand Down
15 changes: 7 additions & 8 deletions OSTLibrary/Chats/Room.cs
Original file line number Diff line number Diff line change
Expand Up @@ -27,14 +27,13 @@ public int FindOtherEmployeeId(Employee myEmp)
if (scopeIdx != 3)
return 0;

foreach(string empStr in target.Split(','))
{
if (empStr == myEmp.id.ToString())
continue;

return int.Parse(empStr);
}
return 0;
string[] targetArr = target.Split(',');

if (targetArr[0] == myEmp.id.ToString())
return int.Parse(targetArr[1]);
else
return int.Parse(targetArr[0]);

}
}
}
2 changes: 1 addition & 1 deletion Server/Classes/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public void Recieve()
else
Log("Room", $"{p.room.target} 채팅방 조회");

Send(new ChatsPacket(Database.GetChats(p.room, p.until)));
Send(new ChatsPacket(Database.GetChats(p.room.id, p.until)));
}
}
else if (packet.type == PacketType.Chat)
Expand Down
4 changes: 2 additions & 2 deletions Server/Classes/Database.cs
Original file line number Diff line number Diff line change
Expand Up @@ -288,11 +288,11 @@ public static Chat GetLastChat(Room room)
}
return null;
}
public static List<Chat> GetChats(Room room, DateTime until)
public static List<Chat> GetChats(string roomId, DateTime until)
{
List<Chat> chats = new List<Chat>();
MySqlCommand cmd = new MySqlCommand(
$"SELECT * FROM chat WHERE room_id='{Filter(room.id)}'"
$"SELECT * FROM chat WHERE room_id='{Filter(roomId)}'"
+ "AND chat_date < @chat_date_until LIMIT 100",
con);
cmd.Parameters.AddWithValue("@chat_date_until", until);
Expand Down

0 comments on commit 4ff4905

Please sign in to comment.