private void HandleResponse(GAISReader gr) { RESPONSE id = (RESPONSE)gr.ReadInt32(); if (id == RESPONSE.NICKNAME_TAKEN) { tcpClient.Close(); MessageBox.Show("Nickname Taken!"); pForm.SetVisibility(true); } }
private void HandleVideoUpdate(GAISReader gr) { String nick = gr.ReadString(); Int32 size = gr.ReadInt32(); Byte[] arr = gr.ReadBytes(size); if (arr.Length > 0) { Program.General.SetImage(arr); } }
private void Run() { while (true) { try { if (tcpClient.Available > 0) { GAISReader gr = new GAISReader(tcpClient.GetStream()); OPCODE op = (OPCODE)gr.ReadInt32(); switch (op) { case OPCODE.RESPONSE: HandleResponse(gr); break; case OPCODE.VIDEO_START: HandleVideoStart(gr); break; case OPCODE.VIDEO_END: HandleVideoEnd(gr); break; case OPCODE.VIDEO_UPDATE: HandleVideoUpdate(gr); break; } } } catch { tcpClient.Close(); } Thread.Sleep(100); } }