StOneDOes Posted July 28, 2017 Share Posted July 28, 2017 Hi guys, I expected the new multiplayer system to be rather easy to use, as I've done manual connection and message sending before, but I can't seem to receive the connect message on the server end. I run the server application first, and then then the client application many seconds later, both on the same PC, but pMessage is always null. I'm also receiving a value in pPeer on the client end, so it seems like there is a successful connection. Can anyone see where I have gone wrong here? Here's what I have at the moment. Server: int main() { Window *pWindow = Window::Create( "Server", 100, 100, 400, 200, Window::Titlebar ); Server *pServer = Server::Create(); Message *pMessage; while( true ) { if( pWindow->Closed() || pWindow->KeyHit( VK_ESCAPE ) ) break; pMessage = pServer->Update(); if( pMessage == nullptr ) continue; if( pMessage->id == Message::Connect ) { cout << "Player connected to the game." << endl; } pMessage->Release(); pMessage = nullptr; } pServer->Release(); pWindow->Release(); return 0; } Client: bool App::Start() { m_pWindow = Window::Create( "Client", 100, 100, 800, 600, Window::Titlebar ); Client *pClient = Client::Create(); Peer *pPeer = pClient->Connect( "127.0.0.1" ); return true; } Thanks in advance. Quote Link to comment Share on other sites More sharing options...
Einlander Posted July 28, 2017 Share Posted July 28, 2017 I think the client needs to have it's own while loop with a Update() call. 1 Quote Link to comment Share on other sites More sharing options...
StOneDOes Posted July 28, 2017 Author Share Posted July 28, 2017 2 hours ago, Einlander said: I think the client needs to have it's own while loop with a Update() call. Thanks for your reply. That will be implemented on the client end when I'm ready, but shouldn't that only be required to actually receive a message from the server? I like to ensure things work step by step, so at the moment I want confirmation that there is an established connection. Quote Link to comment Share on other sites More sharing options...
Solution Einlander Posted July 28, 2017 Solution Share Posted July 28, 2017 A connection is a message that it needs to send. IIRC it will do nothing until the client calls update. 1 Quote Link to comment Share on other sites More sharing options...
StOneDOes Posted July 28, 2017 Author Share Posted July 28, 2017 14 hours ago, Einlander said: A connection is a message that it needs to send. IIRC it will do nothing until the client calls update. Thanks for this. You were right, after calling Update() on the client, the server received the connect message, and the connect messag appeared on the Client end as well. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.