Example #1
0
        public bool StartAsServer(SocketManagement con)
        {
            server       = new ServerObject(con /*this*/); //pass back Socket Managment
            listenThread = new Thread(new ThreadStart(server.Listen));
            listenThread.Start();                          //старт потока

            return(true);
        }
Example #2
0
 private void ConnectAsServer(string ip, int port)
 {
     con = new SocketManagement(ip, port, null);
     con.StartAsServer(con);
     //if (con.StartAsServer())
     //{
     // GameStart();
     //}
 }
Example #3
0
 //part of the network protocol on the client:
 //static TcpClient client;
 //static NetworkStream stream;
 //--------------------------------------------
 public Window1(MainWindow owner, bool isServer, SocketManagement con)
 {
     Loaded       += Window1_MyLoaded;
     this.isMyTurn = isServer;
     this.Owner    = owner;
     this.isServer = isServer;
     //new ResizeForBorderlessForm(this) { AllowResizeAll = false, AllowMove = true };
     InitializeComponent();
     this.con = con;
 }
Example #4
0
 private void ConnectAsClient(string ip, int port)
 {
     client = new TcpClient();
     con    = new SocketManagement(ip, port, client);
     if (con.StartAsClient())
     {
         if (con.amImain())
         {
             isServer = true;
         }//check if it main client
         else
         {
             isServer = false;
         }
         GameStart();//open Window1
     }
 }
Example #5
0
        public int bytesLength = 1212;//data length


        public ServerObject(SocketManagement _CON)
        {
            // _IP = IPAddress.Parse(ip);//not needed
            _PORT = _CON._PORT;
            con   = _CON;
        }
Example #6
0
 public ChatClient(SocketManagement _CON)
 {
     con  = _CON;
     host = con.IP;
     port = con._PORT;//
 }