// 방 나가기 private void button4_Click(object sender, EventArgs e) { if (ClientStatus == CLIENT_STATUS.ROOM) { DevLog.Write($"방 나가기 요청", LOG_LEVEL.INFO); PostSendPacket(PACKET_ID.LeaveRoomReq, null); return; } else { MessageBox.Show("로그인 하지 않았거나, 방에 입장한 상태가 아닙니다."); } }
// 방 만들기 private void button3_Click_1(object sender, EventArgs e) { if (ClientStatus == CLIENT_STATUS.LOGIN) { DevLog.Write($"방 만들기 요청", LOG_LEVEL.INFO); PostSendPacket(PACKET_ID.NewRoomReq, null); return; } else { MessageBox.Show("로그인 하지 않았거나, 방에 입장한 상태입니다."); } }
// 방 입장 private void btnLobbyEnter_Click(object sender, EventArgs e) { if (ClientStatus == CLIENT_STATUS.LOGIN) { DevLog.Write($"방 입장 요청", LOG_LEVEL.INFO); var request = new RoomEnterReqPacket(); request.RoomNumber = textBoxRoomID.Text.ToInt32(); var bodyData = request.ToBytes(); PostSendPacket(PACKET_ID.EnterRoomReq, bodyData); return; } else { MessageBox.Show("로그인 하지 않았거나, 방에 입장한 상태입니다."); } }
private void MainForm_Load(object sender, EventArgs e) { PacketBuffer.Init((8096 * 10), PacketHeaderSize, 1024); IsNetworkThreadRunning = true; NetworkReadThread = new System.Threading.Thread(this.NetworkReadProcess); NetworkReadThread.Start(); NetworkSendThread = new System.Threading.Thread(this.NetworkSendProcess); NetworkSendThread.Start(); dispatcherUITimer = new System.Windows.Threading.DispatcherTimer(); dispatcherUITimer.Tick += new EventHandler(ReadPacketQueueProcess); dispatcherUITimer.Interval = new TimeSpan(0, 0, 0, 0, 100); dispatcherUITimer.Start(); btnDisconnect.Enabled = false; PacketHandler.Init(this); DevLog.Write("프로그램 시작 !!!", LOG_LEVEL.INFO); }
public static void Process(PacketData packet) { var packetType = (PACKET_ID)packet.PacketID; switch (packetType) { case PACKET_ID.SYSTEM_CLIENT_DISCONNECTD: MainFormRef.SetDisconnectd(); break; case PACKET_ID.LoginRes: { var response = new LoginResPacket(); response.FromBytes(packet.BodyData); if (response.Result == ERROR_CODE.NONE) { MainFormRef.SetClientStatus(CLIENT_STATUS.LOGIN); MainFormRef.SetNewRoomNumber(-1); DevLog.Write($"로그인 성공", LOG_LEVEL.INFO); } else { DevLog.Write(string.Format("로그인 실패:{0}", response.Result.ToString()), LOG_LEVEL.ERROR); } } break; case PACKET_ID.NewRoomRes: { var response = new RoomNewResPacket(); response.FromBytes(packet.BodyData); if (response.Result == ERROR_CODE.NONE) { MainFormRef.SetClientStatus(CLIENT_STATUS.ROOM); MainFormRef.SetNewRoomNumber(response.RoomNumber); DevLog.Write($"방 만들기 성공. 방 번호:{response.RoomNumber}", LOG_LEVEL.INFO); } else { DevLog.Write(string.Format("방 만들기 실패:{0}", response.Result.ToString()), LOG_LEVEL.ERROR); } } break; case PACKET_ID.EnterRoomRes: { var response = new RoomEnterResPacket(); response.FromBytes(packet.BodyData); if (response.Result == ERROR_CODE.NONE) { MainFormRef.SetClientStatus(CLIENT_STATUS.ROOM); DevLog.Write($"방 들어가기 성공.", LOG_LEVEL.INFO); } else { DevLog.Write(string.Format("방 들어가기 실패:{0}", response.Result.ToString()), LOG_LEVEL.ERROR); } } break; case PACKET_ID.LeaveRoomRes: { var response = new RoomLeaveResPacket(); response.FromBytes(packet.BodyData); if (response.Result == ERROR_CODE.NONE) { MainFormRef.SetClientStatus(CLIENT_STATUS.LOGIN); MainFormRef.SetNewRoomNumber(-1); DevLog.Write($"방 나가기 성공.", LOG_LEVEL.INFO); } else { DevLog.Write(string.Format("방 나가기 실패:{0}", response.Result.ToString()), LOG_LEVEL.ERROR); } } break; case PACKET_ID.ChatRoomRes: { var response = new RoomChatResPacket(); response.FromBytes(packet.BodyData); if (response.Result == ERROR_CODE.NONE) { DevLog.Write($"채팅 보내기 성공", LOG_LEVEL.INFO); } else { DevLog.Write(string.Format("채팅 실패:{0}", response.Result.ToString()), LOG_LEVEL.ERROR); } } break; case PACKET_ID.ChatRoomNtf: { var response = new RoomChatNotPacket(); response.FromBytes(packet.BodyData); MainFormRef.ChatToUI(response.UserID, response.Message); DevLog.Write($"채팅 알림 받기 성공", LOG_LEVEL.INFO); } break; default: break; } }