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); }
private void ConnectAsServer(string ip, int port) { con = new SocketManagement(ip, port, null); con.StartAsServer(con); //if (con.StartAsServer()) //{ // GameStart(); //} }
//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; }
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 } }
public int bytesLength = 1212;//data length public ServerObject(SocketManagement _CON) { // _IP = IPAddress.Parse(ip);//not needed _PORT = _CON._PORT; con = _CON; }
public ChatClient(SocketManagement _CON) { con = _CON; host = con.IP; port = con._PORT;// }