Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
step4.cpp File Reference
#include <websocketpp/config/asio_no_tls_client.hpp>
#include <websocketpp/client.hpp>
#include <websocketpp/common/thread.hpp>
#include <websocketpp/common/memory.hpp>
#include <cstdlib>
#include <iostream>
#include <map>
#include <string>
#include <sstream>
Include dependency graph for step4.cpp:

Go to the source code of this file.

Classes

class  connection_metadata
 
class  websocket_endpoint
 

Typedefs

typedef websocketpp::client< websocketpp::config::asio_clientclient
 

Functions

std::ostream & operator<< (std::ostream &out, connection_metadata const &data)
 
int main ()
 

Typedef Documentation

◆ client

Function Documentation

◆ main()

int main ( void )

Definition at line 153 of file step4.cpp.

153 {
154 bool done = false;
155 std::string input;
156 websocket_endpoint endpoint;
157
158 while (!done) {
159 std::cout << "Enter Command: ";
160 std::getline(std::cin, input);
161
162 if (input == "quit") {
163 done = true;
164 } else if (input == "help") {
165 std::cout
166 << "\nCommand List:\n"
167 << "connect <ws uri>\n"
168 << "show <connection id>\n"
169 << "help: Display this help text\n"
170 << "quit: Exit the program\n"
171 << std::endl;
172 } else if (input.substr(0,7) == "connect") {
173 int id = endpoint.connect(input.substr(8));
174 if (id != -1) {
175 std::cout << "> Created connection with id " << id << std::endl;
176 }
177 } else if (input.substr(0,4) == "show") {
178 int id = atoi(input.substr(5).c_str());
179
180 connection_metadata::ptr metadata = endpoint.get_metadata(id);
181 if (metadata) {
182 std::cout << *metadata << std::endl;
183 } else {
184 std::cout << "> Unknown connection id " << id << std::endl;
185 }
186 } else {
187 std::cout << "> Unrecognized Command" << std::endl;
188 }
189 }
190
191 return 0;
192}
websocketpp::lib::shared_ptr< connection_metadata > ptr
int connect(std::string const &uri)
connection_metadata::ptr get_metadata(int id) const
Here is the call graph for this function:

◆ operator<<()

std::ostream & operator<< ( std::ostream & out,
connection_metadata const & data )

Definition at line 82 of file step4.cpp.

82 {
83 out << "> URI: " << data.m_uri << "\n"
84 << "> Status: " << data.m_status << "\n"
85 << "> Remote Server: " << (data.m_server.empty() ? "None Specified" : data.m_server) << "\n"
86 << "> Error/close reason: " << (data.m_error_reason.empty() ? "N/A" : data.m_error_reason);
87
88 return out;
89}