I am new to SFML and networking, but not to C++. My information about the chat network comes from someone who works for the site and some bot programmers. The current active programmers that are helping me on the chat network do not know C++ that well, so they can only help me so far.
I just really need some tips on using SFML, like maybe how to make a window that does the same work as a C++ console application and then some. How to set the background color for the window. Some generic tips with creating a non-IRC bot that should work on a chat network if anyone has them.
I've posted my code below. If the link in the code is not appropriate, then I will edit it out. This code is a WIP, but does run (even if it does not have a console to cout to).
#include "SFML/Network.hpp"
#include "SFML/Window.hpp"
#include "SFML/Graphics.hpp"
#include <iostream>
#include <string>
//dA privclass color (188,203,186)
int main(){
sf::TcpSocket socket;
sf::Socket::Status status = socket.connect("chat.deviantart.com", 3900);
if (status != sf::Socket::Done){
std::cout<<"Error! Socket failed!\n";
return EXIT_FAILURE;
}
std::string message = "dAmnClient 0.3\nagent=Test Client\n\0";
socket.send(message.c_str(), message.size() + 1);
char buffer[1024];
std::size_t recieved = 0;
socket.receive(buffer, sizeof(buffer), recieved);
std::cout<<"The server said: "<<buffer<<std::endl;
sf::TcpListener listener;
listener.listen(3900);
listener.accept(socket);
std::cout<<"New client connected: "<< socket.getRemoteAddress()<<std::endl;
return 0;
}
So I looked over the tutorials, as was decided, and decided to add a console back to help me with debugging. My incomplete code has a problem at this part:
sf::Font font;
if(!font.loadFromFile("arial.ttf")){
return -1;
}
The console complains as follows:
Failed to load font "arial.ttf" (failed to create the font face)
Press any key to continue...
I know the tutorial talks about loadFromMemory, but I can't figure out what to put for the second argument.