Exemplo n.º 1
0
        public int bytesLength = 1212;//data length

        public ClientObject(TcpClient tcpClient, ServerObject serverObject, bool _isMain, int currentClientID)
        {
            // Id = Guid.NewGuid().ToString();
            Id     = id.ToString();
            client = tcpClient;
            Stream = client.GetStream();
            server = serverObject;
            try { serverObject.AddConnection(this); } catch (Exception) { }
            isMain           = _isMain;
            _currentClientID = currentClientID;



            //notify the client or it is the main
            int[][] is_Main = new int[3][];
            is_Main[0] = new int[3];
            is_Main[1] = new int[3];
            is_Main[2] = new int[3];
            if (isMain)
            {
                is_Main[0][0] = 1; /*1001*/;
            }
            else
            {
                is_Main[0][0] = 0;
            } /*1000*/;
            //server.BroadcastMessage(new AllData(is_Main, "", false));
            //new2:
            //on first iteration isMain=true
            //server.BroadcastMessage(new AllData(is_Main, Id.ToString(), isMain));
            try { server.ItSelfMessage(new AllData(is_Main, Id.ToString(), isMain)); } catch (Exception) {
                //this method does thing if this is on server (not client)
            };

            id++;
        }