Fix broken examples

This commit is contained in:
fred
2019-05-04 00:07:43 +01:00
parent 52ff3c6e27
commit 12f1d7b0ce
4 changed files with 40 additions and 40 deletions
@@ -14,7 +14,7 @@ int main()
{
//Bind to port, fr::SSLListener should be used for TLS connections
fr::TcpListener listener;
if(listener.listen("9091") != fr::Socket::Success)
if(listener.listen("9091") != fr::Socket::Status::Success)
{
std::cerr << "Failed to bind to port!" << std::endl;
return EXIT_FAILURE;
@@ -29,7 +29,7 @@ int main()
fr::WebFrame frame;
while(true)
{
frame.set_opcode(fr::WebFrame::Text);
frame.set_opcode(fr::WebFrame::Opcode::Text);
std::cout << "Message: " << std::endl;
std::getline(std::cin, message);
if(message == "exit")
@@ -39,7 +39,7 @@ int main()
}
else if(message == "ping")
{
frame.set_opcode(fr::WebFrame::Ping);
frame.set_opcode(fr::WebFrame::Opcode::Ping);
}
frame.set_payload(std::move(message));
socket.send(frame);
@@ -51,7 +51,7 @@ int main()
while(true)
{
//Accept a new WebSocket connection.
if(listener.accept(socket) != fr::Socket::Success)
if(listener.accept(socket) != fr::Socket::Status::Success)
continue;
std::cout << "Accepted new connection: " << socket.get_remote_address() << std::endl;
@@ -60,20 +60,20 @@ int main()
{
//Receive the next frame
fr::WebFrame frame;
if(socket.receive(frame) != fr::Socket::Success)
if(socket.receive(frame) != fr::Socket::Status::Success)
continue;
//If it's a Ping then we need to send back a frame containing the same payload, but of type Pong.
if(frame.get_opcode() == fr::WebFrame::Ping)
if(frame.get_opcode() == fr::WebFrame::Opcode::Ping)
{
std::cout << "Client sent a ping!" << std::endl;
frame.set_opcode(fr::WebFrame::Pong);
frame.set_opcode(fr::WebFrame::Opcode::Pong);
socket.send(frame);
continue;
}
//If it's a disconnect message, then we should finish sending across any messages, and then call disconnect
if(frame.get_opcode() == fr::WebFrame::Disconnect)
if(frame.get_opcode() == fr::WebFrame::Opcode::Disconnect)
{
socket.disconnect();
continue;
@@ -84,9 +84,9 @@ int main()
//a continuation from a previous message. You can check if it's the final part of the
//message using fr::WebFrame::is_final().
std::cout << "Got a new message from the client. It's a ";
if(frame.get_opcode() == fr::WebFrame::Text) std::cout << "text";
else if(frame.get_opcode() == fr::WebFrame::Binary) std::cout << "binary";
else if(frame.get_opcode() == fr::WebFrame::Pong) std::cout << "pong";
if(frame.get_opcode() == fr::WebFrame::Opcode::Text) std::cout << "text";
else if(frame.get_opcode() == fr::WebFrame::Opcode::Binary) std::cout << "binary";
else if(frame.get_opcode() == fr::WebFrame::Opcode::Pong) std::cout << "pong";
else std::cout << "continuation of a previous";
std::cout << " message. It is ";
if(!frame.is_final()) std::cout << "not ";