Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - Shinao

Pages: [1]
1
Hello,

I've finished my project for more than two month now but never got any feedback on it so it will be appreciated.

Link: https://github.com/Shinao/JustAGame

Basically what I wanted to do is a framework for all my mini games, I've had a lot of ideas and simple things to create but I had to redo some things every time and if I wanted to make it multiplayer it was really painful.

What's great about it is the simplicity to integrate a new game. The sample Tic Tac Toe is a shared library that will be loaded on runtime by the game framework when you join a server, if you don't have this game it will download it so that you don't have to keep updating your games manually to the clients.

I don't really use it anymore but some classes can be useful for some people since it's cross-platform. It probably have some bugs since I could not test it on a large scale.

Do you guys have also some libraries/classes that you re-use all the time ? What are they ?

Good day.

2
Network / SocketSelector isReady always return false
« on: April 04, 2014, 07:08:23 am »
Hi,

Here is my minimal example
./a.out foo
will launch the server
and ./a.out will launch the client
The client will send a udp message to the server which will display received.
But if we uncomment the isReady function, then we can see that it always return false.

What am I doing wrong ?
By the way, I just pulled the git repository, so I've got the last 'version'.

#include <SFML/Network.hpp>
#include <SFML/System.hpp>
#include <iostream>

void    server();
void    client();

int     main(int ac, char **av)
{
  if (ac > 1)
    server();
  else
    client();
}

void    server()
{
  sf::SocketSelector _listener;
  sf::UdpSocket _socket;

  _listener.add(_socket);
  if (_socket.bind(25052) != sf::Socket::Done)
  {
    std::cout << "can't bind" << std::endl;
    return ;
  }

  char buffer[1024];
  std::size_t received = 0;
  sf::IpAddress sender;
  unsigned short port;

  _socket.setBlocking(true);
  while (1)
  {
    // if (_listener.isReady(_socket))
    // {
      _socket.receive(buffer, sizeof(buffer), received, sender, port);
      std::cout << "received" << std::endl;
    // }

    sf::sleep(sf::milliseconds(2000));
  }
}

void    client()
{
  sf::UdpSocket _socket;

  if (_socket.bind(52025) != sf::Socket::Done)
  {
    std::cout << "can't bind" << std::endl;
    return ;
  }

  _socket.send("ping", 5, sf::IpAddress::Broadcast, 25052);
}

Pages: [1]