private void SendMessage(string message, Socket receiver) { FrameParser frameParser = new FrameParser(); var dataToSend = frameParser.CreateFrameFromString(message); receiver.Send(dataToSend); }
private string ReceiveMessage(Client client) { IPAddress ip = IPAddress.Parse(((IPEndPoint)client.GetClientSocket().RemoteEndPoint).Address.ToString()); var frameParser = new FrameParser(); while (true) { var receivedData = new byte[1000000]; string receivedString; client.GetClientSocket().Receive(receivedData); if ((receivedData[0] & (byte)Opcode.CloseConnection) == (byte)Opcode.CloseConnection) { Disconnect(client); return(""); } else { receivedString = frameParser.ParsePayloadFromFrame(receivedData); return(receivedString); } } }