Package net.vo

Examples of net.vo.Host


                // 整理信息
                byte[] buf = new byte[broadPacket.getLength()];
                System.arraycopy(broadPacket.getData(), 0, buf, 0, buf.length);
                byteArrayStram = new ByteArrayInputStream(buf);
                objectStream = new ObjectInputStream(byteArrayStram);
                Host host = (Host) objectStream.readObject();
                host.setState(0);

                if (!host.getIp().equals(SystemConf.hostIP)) {
                    if (!NetDomain.containHost(host)) {
                        host.setState(1);
                        NetDomain.addHost(host);
                        System.out.println(SystemConf.hostList.size());

                        // 回应广播, 发送本机信息去目标地址
                        if (host.getTag() == 0) {
                            InetAddress addr = InetAddress.getLocalHost();
                            String hostName = addr.getHostName();// 获取主机名
                            String ip = SystemConf.hostIP;// 获取ip地址

                            Map<String, String> map = System.getenv();
                            String userName = map.get("USERNAME");// 获取用户名
                            String userDomain = map.get("USERDOMAIN");// 获取计算机域

                            // 广播主机信息
                            Host res = new Host(userName, userDomain, ip,
                                    hostName, 1, 1);

                            NetDomain.sendUdpData(broadSocket, res,
                                    host.getIp(), SystemConf.broadcastPort);
                        }
View Full Code Here


    }

    // 检查主机是否重复
    public static synchronized boolean containHost(Host host) {
        for (int i = 0; i < SystemConf.hostList.size(); i++) {
            Host h = SystemConf.hostList.get(i);
            if ((h.getIp().equals(host.getIp()))
                    && (h.getState() == host.getState())) {
                return true;
            }
        }
        return false;
    }
View Full Code Here

            Map<String, String> map = System.getenv();
            userName = map.get("USERNAME");// 获取用户名
            userDomain = map.get("USERDOMAIN");// 获取计算机域

            // 加入在线列表
            Host host = new Host(userName, userDomain, ip, hostName, 1, 0);
            NetDomain.addHost(host);

            logger.info("主机" + ip + "登录成功");

            // 广播登录信息
View Full Code Here

TOP

Related Classes of net.vo.Host

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.