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.


Messages - mihaineken

Pages: [1] 2
1
General discussions / Re: idea needed
« on: April 25, 2015, 10:32:48 am »
I'm sorry, how do I do that ?

2
General discussions / Re: idea needed
« on: April 25, 2015, 12:47:22 am »
Thank you so much for your reply.
Actualy I did some changes but didn't post ...

#include <windows.h>
#include <list>

#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
{
    sf::RenderWindow window( sf::VideoMode( 400, 200), "Server" );

   sf::TcpListener listener ;
   listener.setBlocking( false);

   sf::TcpSocket peer[2] ;
   peer[0].setBlocking( false );
   peer[1].setBlocking( false );
   int max_peers = 0 ;

   std::list <sf::Packet> first_buffer_pack ;
   std::list <sf::Packet> second_buffer_pack ;
   sf::Packet peer_pack ;

   sf::Font font ;
   font.loadFromFile( "Sansation.ttf" );
   sf::Text text ;
   text.setFont( font );
   text.setCharacterSize( 20 );
   text.setColor( sf::Color::White );
   text.setString( "Waiting for peers..." );

   while( window.isOpen( ))
   {
      sf::Event event ;
      window.pollEvent( event );

      if( event.type == sf::Event::Closed )
      {
         window.close( );
      }
      if( max_peers < 2 )
      {
         listener.listen( 31111 );

         if( listener.accept( peer[max_peers]) == sf::Socket::Done )
         {
            text.setString( "Peers conected - " + std::to_string( max_peers+1 ));
            max_peers++ ;
         }
      }
      if( peer[0].receive( peer_pack ) == sf::Socket::Done )
      {
         text.setString( "First peer has send a pack." );
         first_buffer_pack.push_back( peer_pack );
         peer_pack.clear( );
      }
      if( first_buffer_pack.size( ) > 0 && max_peers == 2 )
      {
         if( peer[1].send( first_buffer_pack.front( )) == sf::Socket::Done )
         {
            first_buffer_pack.pop_front( );
            text.setString( "A pack to the second peer has been send." );
         }
      }
      if( peer[1].receive( peer_pack ) == sf::Socket::Done )
      {
         text.setString( "Second peer has send a pack." );
         second_buffer_pack.push_back( peer_pack );
         peer_pack.clear( );
      }
      if( second_buffer_pack.size( ) > 0 && max_peers == 2 )
      {
         if( peer[0].send( second_buffer_pack.front( )) == sf::Socket::Done )
         {
            second_buffer_pack.pop_front( );
            text.setString( "A pack to the first peer has been send." );
         }
      }
      window.clear( );
      window.draw( text );
      window.display( );
   }
    return 0 ;
}


Now the server accept 2 connections and if one peer sends a pack it will remain in the buffer until the next peer will connect.Next I will handle disconnections and after was thinking to put all this code in some class and that way the server will handle multiple peers.As I said I do this for fun but I will return with some updates ;)
Thank you so much !

3
General discussions / Re: idea needed
« on: April 19, 2015, 10:30:07 pm »
Guys please don't take this the wrong way but seems like every time someone ask something is a general thing for you guys to send them away: "Go an learn that !", "Go and search that !".

We are newbees we understand nothing !
Now I am shure that you are great programmers and know alot of things and you study hard.But please don't send us away.

I like programming but is not my job, I do this in my spear time, and who knows.... maybe this thing will bring me someware.

I started this post not because I want you to programm something for me, but I was hopping that someone will come up with some ideea on how to improve what I started.This topic is not that much for you (the big guys that know programming) as it is for the guys like mine who bearly understand something...

I do want that another guy like me will come and say : "How about if we do... "some thing"...it will improve. "
And we start to creat something.This is learning my friends !
Please don't understand me wrong !

4
General discussions / Re: idea needed
« on: April 18, 2015, 11:06:57 pm »
Just because I am using Visual Studio and the project is Win32Project  ;)

5
General discussions / Re: idea needed
« on: April 18, 2015, 07:18:57 pm »
I have write this code :


#include <windows.h>
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>

int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
{
    sf::RenderWindow window( sf::VideoMode( 400, 200), "Server" );

   sf::TcpListener listener ;

   sf::TcpSocket peer[2] ;
   peer[0].setBlocking( false );
   peer[1].setBlocking( false );
   int max_peers = 0 ;

   sf::Packet peer_pack ;

   sf::Font font ;
   font.loadFromFile( "Sansation.ttf" );
   sf::Text text ;
   text.setFont( font );
   text.setCharacterSize( 20 );
   text.setColor( sf::Color::White );
   text.setString( "Waiting for peers..." );

   while( window.isOpen( ))
   {
      sf::Event event ;
      window.pollEvent( event );

      if( event.type == sf::Event::Closed )
      {
         window.close( );
      }
      if( max_peers < 2 )
      {
         listener.listen( 31111 );

         if( listener.accept( peer[max_peers]) == sf::Socket::Done )
         {
            text.setString( "Peers conected - " + std::to_string( max_peers+1 ));
            max_peers++ ;
         }
      }
      if( peer[0].receive( peer_pack ) == sf::Socket::Done )
      {
         text.setString( "First peer has send a pack." );
         peer[1].send( peer_pack );
         peer_pack.clear( );
         text.setString( "A pack to the second peer has been send." );
      }
      if( peer[1].receive( peer_pack ) == sf::Socket::Done )
      {
         text.setString( "Second peer has send a pack." );
         peer[0].send( peer_pack );
         peer_pack.clear( );
         text.setString( "A pack to the first peer has been send." );
      }
      window.clear( );
      window.draw( text );
      window.display( );
   }
    return 0 ;
}

The server accept 2 peers, and if one sends a pack, it will be redirected to the other one.
So what do you think ? :)

6
General discussions / Re: idea needed
« on: April 18, 2015, 12:52:23 pm »
I can feel your sarcasm... and understand that you must answer alot of dump question and you must be tired, but I also think that this can be a nice topic and everyone can come up with some ideas...it can be as simple as that: How would you do this ?

I remind that this is a post in General discussions, not in Help !
Come on, be friendly ; )

7
General discussions / idea needed
« on: April 18, 2015, 10:20:32 am »
Hello !

I need to do a server, but ideas are not comming ...
The server must accept new connections and pair clients 2 by 2.
After the server understands that those 2 clients must be paired, server accept package from one client and send to the other one.

Let's say that client1 connects to my server and client2 connects to my server.
They all send a string so my server could recognise them.Based on that string, my server knows that if client1 sends a pack, then the server must send that pack to client2, and if client2 sends a pack, then it must be send to client1.

Anyone have some ideas on how to build this thing ?
Thank you !  ;)

8
Network / Re: Extracting Ip adress from a file
« on: March 14, 2015, 10:29:47 am »
Count the number of characters that you read, or print them as integers rather than characters, or anything else that makes 100% sure that the string really is what you expect. You may have a trailing \n or EOF.


It does work if you whrite the IP adress corectly in the file. :))
Stupid me !!
Sorry guys...

9
Network / Re: AW: Extracting Ip adress from a file
« on: March 12, 2015, 10:25:43 pm »
If I try to display that string as text, it displays correctly.

10
Network / Extracting Ip adress from a file
« on: March 12, 2015, 09:19:48 pm »
I have made a client that needs to connect to an IP adress that is stored in a file.
The file contains only the IP adress.
I have extracted the IP adress character by character and store it into a std::string.
The string is passed in the connecting function and doesn't work.

Here is the code :

#include <windows.h>
#include <SFML/Graphics.hpp>
#include <SFML/Network.hpp>
#include <iostream>
#include <fstream>


int WINAPI wWinMain(HINSTANCE hInstance, HINSTANCE, PWSTR pCmdLine, int nCmdShow)
{
        sf::RenderWindow window(sf::VideoMode(800, 400), "The Game" );

        sf::Font font ;
        sf::Text text ;

        std::string IP ;  //The string that will be passed as the IP adress
        std::ifstream file_in( "IP.txt" ); //The file that contains the IP adress
        char input_line ;

        sf::TcpSocket socket_client ;

        font.loadFromFile( "Sansation.ttf" );
        text.setFont( font );
        text.setCharacterSize( 20 );
        text.setColor( sf::Color::White );
       
        while( file_in.get( input_line ))  //Extracting char from the line in the file
        {
                IP += input_line ;
        }
        file_in.close() ;

        sf::Socket::Status status_client = socket_client.connect( IP , 31111 );

        //In the line above, if I pass the IP adress as "192.168.10.10" instead of IP, it will connect

        if( status_client == sf::Socket::Done )
        {
                text.setString( "Connected" );
        }

        while (window.isOpen())
        {
                sf::Event event;
                 while (window.pollEvent(event))
                 {
                         if (event.type == sf::Event::Closed)
                                 window.close();
                 }
                 window.clear();

                 window.draw( text );

                 window.display();
        }

    return 0;
}

11
General discussions / Re: a rummy game
« on: June 27, 2014, 10:28:44 pm »
Thank you all for your answers.

12
General discussions / Re: a rummy game
« on: June 27, 2014, 10:26:19 pm »
OMG for that amount of money i quit my job and start programming for real.
 :) for me, that sum is astronomical.

13
General discussions / Re: a rummy game
« on: June 27, 2014, 07:15:58 pm »
Because i what one and i don't have time to create it.

14
General discussions / Re: a rummy game
« on: June 27, 2014, 06:02:28 am »
Are you asking how much it would cost for someone to make you a rummy game in SFML?   ???



Yes !

15
General discussions / a rummy game
« on: June 26, 2014, 10:35:53 pm »
how much does a game of rummy cost, whrited with sfml ?
can anyone estimate ?

Pages: [1] 2