|
|
@ -25,10 +25,11 @@ namespace Client |
|
|
|
private void InitInstance() |
|
|
|
private void InitInstance() |
|
|
|
{ |
|
|
|
{ |
|
|
|
Singleton.Instance.CreateRoomResponsed += CreateRoomResponsed; |
|
|
|
Singleton.Instance.CreateRoomResponsed += CreateRoomResponsed; |
|
|
|
Singleton.Instance.RoomListResponsed += Instance_RoomListResponsed; |
|
|
|
Singleton.Instance.RoomListResponsed += RoomListResponsed; |
|
|
|
|
|
|
|
Singleton.Instance.EnterRoomResponsed += EnterRoomResponsed; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void btnEnter_Click(object sender, EventArgs e) |
|
|
|
private async void btnEnter_Click(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (lbxRoom.SelectedItem == null) |
|
|
|
if (lbxRoom.SelectedItem == null) |
|
|
|
{ |
|
|
|
{ |
|
|
@ -36,14 +37,8 @@ namespace Client |
|
|
|
return; |
|
|
|
return; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
IAsyncResult ar = null; |
|
|
|
EnterRoomRequestPacket packet = new EnterRoomRequestPacket(lbxRoom.SelectedItem.ToString()); |
|
|
|
ar = BeginInvoke(() => |
|
|
|
await Singleton.Instance.SendAsync(packet.Serialize(), SocketFlags.None); |
|
|
|
{ |
|
|
|
|
|
|
|
ChatRoomForm chatRoomForm = new ChatRoomForm(); |
|
|
|
|
|
|
|
chatRoomForm.Text = lbxRoom.SelectedItem.ToString(); |
|
|
|
|
|
|
|
chatRoomForm.ShowDialog(); |
|
|
|
|
|
|
|
EndInvoke(ar); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async void btnCreate_Click(object sender, EventArgs e) |
|
|
|
private async void btnCreate_Click(object sender, EventArgs e) |
|
|
@ -105,7 +100,7 @@ namespace Client |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private void Instance_RoomListResponsed(object? sender, EventArgs e) |
|
|
|
private void RoomListResponsed(object? sender, EventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (sender == null) |
|
|
|
if (sender == null) |
|
|
|
return; |
|
|
|
return; |
|
|
@ -120,6 +115,25 @@ namespace Client |
|
|
|
}); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void EnterRoomResponsed(object? sender, EventArgs e) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
if (sender == null) |
|
|
|
|
|
|
|
return; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
EnterRoomResponsePacket packet = (EnterRoomResponsePacket)sender; |
|
|
|
|
|
|
|
InvokeMethod(() => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
IAsyncResult ar = null; |
|
|
|
|
|
|
|
ar = BeginInvoke(() => |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
ChatRoomForm chatRoomForm = new ChatRoomForm(); |
|
|
|
|
|
|
|
chatRoomForm.Text = lbxRoom.SelectedItem.ToString(); |
|
|
|
|
|
|
|
chatRoomForm.ShowDialog(); |
|
|
|
|
|
|
|
EndInvoke(ar); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
}); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
private async void btnRefresh_Click(object sender, EventArgs e) |
|
|
|
private async void btnRefresh_Click(object sender, EventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
lbxRoom.Items.Clear(); |
|
|
|
lbxRoom.Items.Clear(); |
|
|
@ -130,7 +144,9 @@ namespace Client |
|
|
|
private void RoomListForm_FormClosing(object sender, FormClosingEventArgs e) |
|
|
|
private void RoomListForm_FormClosing(object sender, FormClosingEventArgs e) |
|
|
|
{ |
|
|
|
{ |
|
|
|
Singleton.Instance.CreateRoomResponsed -= CreateRoomResponsed; |
|
|
|
Singleton.Instance.CreateRoomResponsed -= CreateRoomResponsed; |
|
|
|
Singleton.Instance.RoomListResponsed -= Instance_RoomListResponsed; |
|
|
|
Singleton.Instance.RoomListResponsed -= RoomListResponsed; |
|
|
|
|
|
|
|
Singleton.Instance.EnterRoomResponsed -= EnterRoomResponsed; |
|
|
|
|
|
|
|
|
|
|
|
Singleton.Instance.Socket.Shutdown(SocketShutdown.Send); |
|
|
|
Singleton.Instance.Socket.Shutdown(SocketShutdown.Send); |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|