Example #1
0
        static void Main(string[] args)
        {
            CPacketBufferManager.initialize(2000);
            CNetworkService service = new CNetworkService();

            CConnector connector = new CConnector(service);

            connector.connected_callback += on_connected_gameserver;
            IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7979);

            connector.connect(endpoint);

            while (true)
            {
                Console.Write("> ");
                string line = Console.ReadLine();
                if (line == "q")
                {
                    break;
                }

                CPacket msg = CPacket.create((short)PROTOCOL.CHAT_MSG_REQ);
                msg.push(line);
                game_servers[0].send(msg);
            }

            ((CRemoteServerPeer)game_servers[0]).token.disconnect();

            Console.ReadKey();
        }
        public void connect(string host, int port)
        {
            if (this.service != null)
            {
                Debug.LogError("re connected.");
                CConnector connector = new CConnector(service);
                // 접속 성공시 호출될 콜백 매소드 지정.
                connector.connected_callback += on_connected_gameserver;

                //4바이트아이피
                IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(host), port);
                connector.connect(endpoint, AddressFamily.InterNetwork);
                return;
            }
            else
            {
                // CNetworkService객체는 메시지의 비동기 송,수신 처리를 수행한다.
                this.service = new CNetworkService();

                // endpoint정보를 갖고있는 Connector생성. 만들어둔 NetworkService객체를 넣어준다.
                CConnector connector = new CConnector(service);
                // 접속 성공시 호출될 콜백 매소드 지정.
                connector.connected_callback += on_connected_gameserver;

                //4바이트아이피
                IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(host), port);
                connector.connect(endpoint, AddressFamily.InterNetwork);
            }
        }
        public void iosconnect(int port)
        {
            if (this.service != null)
            {
                Debug.LogError("re connected.");
                CConnector connector = new CConnector(service);
                // 접속 성공시 호출될 콜백 매소드 지정.
                connector.connected_callback += on_connected_gameserver;

                IPAddress ipAddr = GetIPV6("ec2-52-197-124-209.ap-northeast-1.compute.amazonaws.com");
                if (ipAddr != null)
                {
                    IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 49495);
                    connector.connect(ipEndPoint, ipAddr.AddressFamily);
                }
                else
                {
                    ipAddr = GetIPV4("ec2-52-197-124-209.ap-northeast-1.compute.amazonaws.com");
                    if (ipAddr != null)
                    {
                        IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 49494);
                        connector.connect(ipEndPoint, ipAddr.AddressFamily);
                    }
                }
                return;
            }
            else
            {
                // CNetworkService객체는 메시지의 비동기 송,수신 처리를 수행한다.
                this.service = new CNetworkService();

                // endpoint정보를 갖고있는 Connector생성. 만들어둔 NetworkService객체를 넣어준다.
                CConnector connector = new CConnector(service);
                // 접속 성공시 호출될 콜백 매소드 지정.
                connector.connected_callback += on_connected_gameserver;

                IPAddress ipAddr = GetIPV6("ec2-52-197-124-209.ap-northeast-1.compute.amazonaws.com");
                if (ipAddr != null)
                {
                    IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 49495);
                    connector.connect(ipEndPoint, ipAddr.AddressFamily);
                }
                else
                {
                    ipAddr = GetIPV4("ec2-52-197-124-209.ap-northeast-1.compute.amazonaws.com");
                    if (ipAddr != null)
                    {
                        IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 49494);
                        connector.connect(ipEndPoint, ipAddr.AddressFamily);
                    }
                }
            }
        }
        public void connects(string DnsName, int port)
        {
            if (this.service != null)
            {
                Debug.LogError("re connected.");
                CConnector connector = new CConnector(service);
                // 접속 성공시 호출될 콜백 매소드 지정.
                connector.connected_callback += on_connected_gameserver;

                //IPAddress ipAddr = GetIPV6(DnsName);
                //if (ipAddr != null)
                //{
                //    IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 49495);
                //    connector.connect(ipEndPoint, ipAddr.AddressFamily);
                //}
                //else
                {
                    IPAddress ipAddr = GetIPV4(DnsName);
                    if (ipAddr != null)
                    {
                        IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 49494);
                        connector.connect(ipEndPoint, ipAddr.AddressFamily);
                    }
                }
                return;
            }
            else
            {
                // CNetworkService객체는 메시지의 비동기 송,수신 처리를 수행한다.
                this.service = new CNetworkService();

                // endpoint정보를 갖고있는 Connector생성. 만들어둔 NetworkService객체를 넣어준다.
                CConnector connector = new CConnector(service);
                // 접속 성공시 호출될 콜백 매소드 지정.
                connector.connected_callback += on_connected_gameserver;

                //IPAddress ipAddr = GetIPV6(DnsName);
                //if (ipAddr != null)
                //{
                //    IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 49495);
                //    connector.connect(ipEndPoint, ipAddr.AddressFamily);
                //}
                //else
                {
                    IPAddress ipAddr = GetIPV4(DnsName);
                    if (ipAddr != null)
                    {
                        IPEndPoint ipEndPoint = new IPEndPoint(ipAddr, 49494);
                        connector.connect(ipEndPoint, ipAddr.AddressFamily);
                    }
                }
            }
        }
Example #5
0
        public static void load()
        {
            CPacketBufferManager.initialize(2000);
            CNetworkService service = new CNetworkService(true);

            CConnector connector = new CConnector(service);

            connector.connected_callback += on_connected_gameserver;
            IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7979);

            connector.connect(endpoint);
        }
Example #6
0
        public void connect(string host, int port)
        {
            // CNetworkService객체는 메시지의 비동기 송,수신 처리를 수행한다.
            this.service = new CNetworkService();

            // endpoint정보를 갖고있는 Connector생성. 만들어둔 NetworkService객체를 넣어준다.
            CConnector connector = new CConnector(service);

            // 접속 성공시 호출될 콜백 매소드 지정.
            connector.connected_callback += on_connected_gameserver;
            IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(host), port);

            connector.connect(endpoint);
        }
Example #7
0
        private CClient()
        {
            CPacketBufferManager.initialize(2000);
            service          = new CNetworkService();
            serverlist       = new List <IPeer>();
            waiting_userlist = new List <string>();

            connector = new CConnector(service);

            connector.connected_callback    += on_connected_server;
            connector.reconnection_callback += reconnect_server;

            end_point = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7979);

            connect_server();
        }
        public void connect(string host, int port)
        {
            if (this.service != null)
            {
                Debug.LogError("Already connected.");
                return;
            }

            // CNetworkService��ü�� �޽����� �񵿱� ��,���� ó���� �����Ѵ�.
            this.service = new CNetworkService();

            // endpoint������ �����ִ� Connector����. ������ NetworkService��ü�� �־��ش�.
            CConnector connector = new CConnector(service);
            // ���� ������ ȣ��� �ݹ� �żҵ� ����.
            connector.connected_callback += on_connected_gameserver;
            IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(host), port);
            connector.connect(endpoint);
        }
Example #9
0
        static public void SrvrConn()
        {
            CPacketBufferManager.initialize(2000);
            // CNetworkService객체는 메시지의 비동기 송,수신 처리를 수행한다.
            // 메시지 송,수신은 서버, 클라이언트 모두 동일한 로직으로 처리될 수 있으므로
            // CNetworkService객체를 생성하여 Connector객체에 넘겨준다.
            CNetworkService service = new CNetworkService();

            // endpoint정보를 갖고있는 Connector생성. 만들어둔 NetworkService객체를 넣어준다.
            CConnector connector = new CConnector(service);

            // 접속 성공시 호출될 콜백 매소드 지정.
            connector.connected_callback += on_connected_gameserver;
            IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse("192.168.0.188"), 7979);

            connector.connect(endpoint);
            System.Threading.Thread.Sleep(10);
        }
Example #10
0
        public void connect(string host, int port)
        {
            if (this.service != null)
            {
                Debug.LogError("aleady connected.");
                return;
            }

            // CNetworkService객체는 메시지의 비동기 송, 수신 처리를 수행한다.
            this.service = new CNetworkService();

            // EndPoint 정보를 갖고 있는 Connector 생성. 만들어둔 NetworkService 객체를 넣어준다
            CConnector connector = new CConnector(service);

            // 접속 성공시 호출될 콜백 메소드 지정.
            connector.connected_callback += on_connected_gameserver;
            IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse(host), port);

            connector.connect(endpoint);
        }
        static void Main(string[] args)
        {
            CPacketBufferManager.initialize(2000);

            // CNetworkService 객체는 메시지의 비동기 송, 수신 처리를 수행합니다.
            // 메시지 송, 수신은 서버, 클라이언트 모두 동일한 로직으로 처리될 수 있으므로
            // CNetworkService 객체를 생성하여 Connector 객체에 넘겨줍니다.
            CNetworkService service = new CNetworkService();

            // endPoint 정보를 갖고 있는 Connector 생성, 만들어준 CNetworkSErvice 객체를 넣어줍니다.
            CConnector connector = new CConnector(service);

            // 접속 성공시 호출될 콜백 메소드 지정
            connector.connected_callback += on_connected_gameserver;

            IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7979);

            connector.connect(endpoint);

            while (true)
            {
                Console.Write("> ");

                // 키보드 입력을 받을 수 있도록 ReadLine 메소드를 호출해준다.
                string line = Console.ReadLine();

                // q 한글자 입력 경우 종료
                if (line == "q" || line == "Q")
                {
                    break;
                }

                CPacket msg = CPacket.create((short)PROTOCOL.CHAT_MSG_REQ);
                msg.push(line);
                game_servers[0].send(msg);
            }

            ((CRemoteServerPeer)game_servers[0]).token.disconnect();

            Console.ReadKey();
        }
Example #12
0
        static void Main(string[] args)
        {
            CPacketBufferManager.initialize(2000);
            // CNetworkService객체는 메시지의 비동기 송,수신 처리를 수행한다.
            // 메시지 송,수신은 서버, 클라이언트 모두 동일한 로직으로 처리될 수 있으므로
            // CNetworkService객체를 생성하여 Connector객체에 넘겨준다.
            CNetworkService service = new CNetworkService();

            // endpoint정보를 갖고있는 Connector생성. 만들어둔 NetworkService객체를 넣어준다.
            CConnector connector = new CConnector(service);

            // 접속 성공시 호출될 콜백 매소드 지정.
            connector.connected_callback += on_connected_gameserver;
            IPEndPoint endpoint = new IPEndPoint(IPAddress.Parse("127.0.0.1"), 7979);

            connector.connect(endpoint);
            //System.Threading.Thread.Sleep(10);

            while (true)
            {
                Console.Write("> ");
                string line = Console.ReadLine();
                if (line == "q")
                {
                    break;
                }

                CPacket msg = CPacket.create((short)PROTOCOL.CHAT_MSG_REQ);
                msg.push(line);
                game_servers[0].send(msg);
            }

            ((CRemoteServerPeer)game_servers[0]).token.disconnect();

            //System.Threading.Thread.Sleep(1000 * 20);
            Console.ReadKey();
        }
Example #13
0
 public void Copy(CConnector connector)
 {
     p1 = connector.p1;
     p2 = connector.p2;
 }